Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
efa
Posts: 2
Joined: Fri Oct 09, 2020 9:19 pm

Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby efa » Fri Oct 09, 2020 9:28 pm

hi,
the line thickness when importing DXF is wrong.
The exported files become corrupt lost thickness information.

Open a DXF file with line thinckness set, use the attached as test.
The line property "polyline width" is not rendered
Export as DXF
Open the exported DXF with QCAD pro, the line thinkness is wrong

the problem is present in LibreCAD and QCAD Community edition too, see:
https://sourceforge.net/p/librecad/bugs/520/

QCAD Pro and Autodesk TrueView open DXF correctly
Attachments
PCBtracks_demo_FreeCAD.png
PCBtracks_demo_FreeCAD.png (151.1 KiB) Viewed 500 times
PCBtracks_demo.png
PCBtracks_demo.png (116.86 KiB) Viewed 584 times
PCBtracks_demo.7z
(14.48 KiB) Downloaded 15 times
Last edited by efa on Sat Oct 10, 2020 8:08 pm, edited 1 time in total.
efa
Posts: 2
Joined: Fri Oct 09, 2020 9:19 pm

Re: DXF files open with wrong line thickness. Resaving lost thickness information

Postby efa » Sat Oct 10, 2020 6:26 am

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22665 (Git)
Build type: Release
Branch: master
Hash: b0d7850406e046f3b7a8cd5da261e7d54df6bd99
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: Italian/Italy (it_IT)

happen also on Linux with last stable:

OS: LMDE 4 (debbie)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.
Build type: Release
Python version: 2.7.16rc1
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)

Here the link to the isse:
https://tracker.freecadweb.org/view.php?id=4454
User avatar
chennes
Posts: 1065
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby chennes » Sun Feb 07, 2021 8:18 pm

In looking at the code, the DXF output from TechDraw is still using the old Drawing code: there is a "TODO" note in there about replacing it. I don't know if anyone is working on that project, but that's probably what needs to happen to support line thickness. There is some code in there that is trying to render it (though it doesn't seem the have an effect for me, or it's a very small one), but line thickness doesn't look like it's being output at all, or rather, is being written as a single hardcoded value.
Chris Hennes
Pioneer Library System
User avatar
Kunda1
Posts: 10962
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby Kunda1 » Sun Feb 07, 2021 9:17 pm

chennes wrote: Sun Feb 07, 2021 8:18 pm In looking at the code, the DXF output from TechDraw is still using the old Drawing code: there is a "TODO" note in there about replacing it. I don't know if anyone is working on that project, but that's probably what needs to happen to support line thickness. There is some code in there that is trying to render it (though it doesn't seem the have an effect for me, or it's a very small one), but line thickness doesn't look like it's being output at all, or rather, is being written as a single hardcoded value.
Thanks @chennes
realthunder said something about Techdraw during his talk. I think that some of it relies on some OCC kernel that makes it very difficult to use. Perhaps ot would be good to discuss any ideas about this with him since this is something he wants to tackle. Perhaps circumventing the need to use OCC at all to render TD stuff. Sorry, this may not be relevant but I just wanted to make sure i mentioned this so efforts won't be duplicated, as this was something you also mentioned above. ;)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
chennes
Posts: 1065
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby chennes » Thu Aug 26, 2021 3:27 am

I took a closer look at this tonight, and actually as far as I can determine it's not possible for FreeCAD as it currently exists to import a DXF with line width information and to then re-export lines with that width. Maybe someone more familiar with the process can make sure I'm understanding correctly:

The DXF standard allows "thickness" to be specified for all components, from lines to vertices. But as far as I am aware, FreeCAD doesn't have this idea of a line with a width: lines are simply lines in the mathematical sense, and are rendered with whatever width the user has configured in their overall display preferences. So the DXF importer can fake line width by creating polygons instead of lines, but when this is re-exported, that's what's going into the file: polygons, not lines with a width.

It's not clear to me if there's a way to store some sort of additional data in FreeCAD that would assign a specified width to each line and use it when rendering the line (and when writing it back out to DXF).
Chris Hennes
Pioneer Library System
carlopav
Posts: 1915
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby carlopav » Thu Aug 26, 2021 6:16 am

I think you are right @chennes.
To have polyline width representation, we should have an equivalent FC object that can store data the sameway a dxf polyline does and represent It through faces, but keeps polyline data and allows Edit It.
What can be more similar Is Draft_Wire, but in the reality, we miss that particolar object.
Perhaps we could do a workaround: import the polyline as a Part::Feature (Wire) and apply a Part Offset with polyline (constant) widt?
Edit: Perhaps it's too hacky
follow my experiments on BIM modelling for architecture design
User avatar
Roy_043
Posts: 3610
Joined: Thu Dec 27, 2018 12:28 pm

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby Roy_043 » Thu Aug 26, 2021 8:52 am

Note that in DwgCAD each segment of a 2D polyline can have its own start and end width.
User avatar
Roy_043
Posts: 3610
Joined: Thu Dec 27, 2018 12:28 pm

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby Roy_043 » Thu Aug 26, 2021 9:12 am

It is certainly possible to get a much better import result. See the attachments.

IMO this issue should be reclassified as a feature request.
Attachments
PCBtracks_demo.png
PCBtracks_demo.png (30.53 KiB) Viewed 190 times
PCBtracks_demo-dxf-prefs.png
PCBtracks_demo-dxf-prefs.png (53.53 KiB) Viewed 190 times
PCBtracks_demo.FCStd
(448.45 KiB) Downloaded 2 times
User avatar
chennes
Posts: 1065
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby chennes » Thu Aug 26, 2021 2:32 pm

Roy_043 wrote: Thu Aug 26, 2021 9:12 am It is certainly possible to get a much better import result.
Yes, absolutely -- converting the polylines into rectangles via the "Render Polylines with Width" option lets FreeCAD "fake" the line width behavior in cases where all vertices have the same width. But this does not quite do what the reporter seems to expect: if you then re-export that DXF, you now have rectangles rather than lines. I don't know if that's adequate to their purpose. I certainly agree that this is a feature request, not a bug -- we don't claim to support 100% of the DXF standard, and never will.
Chris Hennes
Pioneer Library System
User avatar
Roy_043
Posts: 3610
Joined: Thu Dec 27, 2018 12:28 pm

Re: Ticket #4454 - DXF files open with wrong line thickness. Resaving lost thickness information

Postby Roy_043 » Thu Aug 26, 2021 2:49 pm

chennes wrote: Thu Aug 26, 2021 2:32 pm we don't claim to support 100% of the DXF standard, and never will.
Exactly.