[Feature Request] Hidden line differentiation in DXF export
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- davecoventry
- Posts: 286
- Joined: Mon Dec 09, 2013 8:11 pm
- Location: Johannesburg
- Contact:
[Feature Request] Hidden line differentiation in DXF export
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)
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
- wandererfan
- Veteran
- Posts: 6317
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Feature Request] Hidden line differentiation in DXF export
I don't think the DXF exporter knows about appearance attributes, just geometry.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.
The SVG exporter is part of the same code that draws on screen, so it knows about colours, widths, etc.
- davecoventry
- Posts: 286
- Joined: Mon Dec 09, 2013 8:11 pm
- Location: Johannesburg
- Contact:
Re: [Feature Request] Hidden line differentiation in DXF export
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!
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
- wandererfan
- Veteran
- Posts: 6317
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Feature Request] Hidden line differentiation in DXF export
Non-trival would cover it.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?
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.
- davecoventry
- Posts: 286
- Joined: Mon Dec 09, 2013 8:11 pm
- Location: Johannesburg
- Contact:
Re: [Feature Request] Hidden line differentiation in DXF export
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.
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
Re: [Feature Request] Hidden line differentiation in DXF export
Go for it!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.
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
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
- wandererfan
- Veteran
- Posts: 6317
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Feature Request] Hidden line differentiation in DXF export
The code that converts the screen image to SVG comes from Qt (QSvgGenerator).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.
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
- davecoventry
- Posts: 286
- Joined: Mon Dec 09, 2013 8:11 pm
- Location: Johannesburg
- Contact:
Re: [Feature Request] Hidden line differentiation in DXF export
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.
I see there is a file QGVPage.cpp which seems to call QSvgGenerator, I'll look at that.
~ Dave
- davecoventry
- Posts: 286
- Joined: Mon Dec 09, 2013 8:11 pm
- Location: Johannesburg
- Contact:
Re: [Feature Request] Hidden line differentiation in DXF export
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.
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
Re: [Feature Request] Hidden line differentiation in DXF export
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
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