[Feature Request] Hidden line differentiation in DXF export

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

[Feature Request] Hidden line differentiation in DXF export

Post by davecoventry »

TechDraw already has the option to define hidden lines with colours and linetypes, but (as far as I can see) no way of imparting this information to an exported dxf file.

If I define 'Hard Hidden' lines as (say) magenta, this is not reflected in the DXF exported file.

It IS passed to the svg file, though, which makes me think that it would be trivial to define the line's colour or assign it to a layer based on these.

Many thanks for a great piece of software.

OS: KDE neon User - Plasma 25th Anniversary Edition (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.20.27050 (Git)
Build type: Unknown
Branch: master
Hash: 70d61b96241a7b54eb0fba4b993e35928ba46f80
Python version: 3.8.10
Qt version: 5.15.3
Coin version: 4.0.0
OCC version: 7.3.0
Locale: English/South Africa (en_ZA)
~ Dave
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Feature Request] Hidden line differentiation in DXF export

Post by wandererfan »

davecoventry wrote: Mon Jan 17, 2022 9:59 am It IS passed to the svg file, though, which makes me think that it would be trivial to define the line's colour or assign it to a layer based on these.
I don't think the DXF exporter knows about appearance attributes, just geometry.

The SVG exporter is part of the same code that draws on screen, so it knows about colours, widths, etc.
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: [Feature Request] Hidden line differentiation in DXF export

Post by davecoventry »

Thanks for the response, WF.

What you are saying is that it would not be trivial to pass that information to the DXF exporter?

Pity. Currently I'm exporting 2 versions of the projected 2D view: one with hidden lines which is assigned to a layer with grey line colour and hidden linetype and the other which is continuous linetype in hard black and the file sizes are humungous!
~ Dave
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Feature Request] Hidden line differentiation in DXF export

Post by wandererfan »

davecoventry wrote: Mon Jan 17, 2022 6:44 pm What you are saying is that it would not be trivial to pass that information to the DXF exporter?
Non-trival would cover it.

There are actually 2 DXF exporters in FreeCAD - one that is part of Draft and one in the Import module. I think the Draft version knows about appearance attributes, but it works on the 3D model, not TechDraw pages. The Import version is dumb as a post when it comes to appearances and that's the one that TechDraw uses.
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: [Feature Request] Hidden line differentiation in DXF export

Post by davecoventry »

Ok, so the better way would be to adapt the SVG exporter to output DXF files.

Would that be feasible?

Where does the code for the SVG exporter reside? If I grep through the code for "<path " string, I see that all the files are python files, but some are in directories like /Mod/Draft/Draft_rc,py, Mod/Draft/draftfunctions/svgshapes.py, Mod/Tux/Tux_rc.py, Mod/Draft/draftfunctions/svgshapes.py.

I see there is a cpp file, too:Mod/Drawing/App/DrawingExport.cpp

I am self taught as a programmer and my code would horrify any proper software coder, but I wouldn't mind seeing if I could get this to work.
~ Dave
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Feature Request] Hidden line differentiation in DXF export

Post by Kunda1 »

davecoventry wrote: Thu Jan 20, 2022 10:48 am I am self taught as a programmer and my code would horrify any proper software coder, but I wouldn't mind seeing if I could get this to work.
Go for it!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Feature Request] Hidden line differentiation in DXF export

Post by wandererfan »

davecoventry wrote: Thu Jan 20, 2022 10:48 am Ok, so the better way would be to adapt the SVG exporter to output DXF files.
The code that converts the screen image to SVG comes from Qt (QSvgGenerator).

Inkscape will convert SVG to DXF. I haven't used this facility, but there are instructions here: https://kellylollardesigns.com/blogs/ne ... svg-to-dxf
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: [Feature Request] Hidden line differentiation in DXF export

Post by davecoventry »

Using Inkscape doesn't really work, I'm afraid. It's very unwieldy, takes ages to load and messes with the scale. You can place all elements of the same colour on a separate layer, which does allow the preservation of the line data, but it's very slow for a biggish drawing and it frequently locks up (I have a decent setup with a Ryzen7 4.0GHz and 20Gig of Ram)

I see there is a file QGVPage.cpp which seems to call QSvgGenerator, I'll look at that.
~ Dave
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: [Feature Request] Hidden line differentiation in DXF export

Post by davecoventry »

A far better method is to use QCAD, which is a quasi opensource CAD program.

FreeCAD exports the colour information using stroke="#ff00ff", which unfortunately, QCAD doesn't recognise.

However, if one changes this to style="stroke:#ff00ff", then the colour data is maintained.

One can save it in Inkscape which will change this, but this is unwieldy, takes forever and is prone to crashing.

Instead, simply run

sed -i 's/stroke=\"#ff00ff\"/style=\"stroke:#ff00ff\"/g' FreeCAD.svg

Then use the QCAD File->SVG Import function to import drawing with line colours intact.
~ Dave
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Feature Request] Hidden line differentiation in DXF export

Post by Kunda1 »

Maybe the feature request here is to get TD to use the Draft SVG exporter ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply