Dxf Spline Export

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Dxf Spline Export

Post by wandererfan »

easyw-fc wrote: Wed Jun 13, 2018 8:18 pm ping
continued from Dxf Export of Dimension

as @jaisejames suggested, I think spline support in R12 is sketchy at best. If you set import/export preferences to "splines as polylines" you should get a better result.
splineAsPolyline.png
splineAsPolyline.png (147.71 KiB) Viewed 3113 times
splineAsSpline.png
splineAsSpline.png (145.88 KiB) Viewed 3113 times
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Dxf Spline Export

Post by easyw-fc »

wandererfan wrote: Thu Jun 14, 2018 4:04 pm as @jaisejames suggested, I think spline support in R12 is sketchy at best. If you set import/export preferences to "splines as polylines" you should get a better result.
I know that R12 doesn't support splines
Then there is the option in case a spline is encountered, to let the exporter ask to convert spline to poly line or change the format to R14 at least to support spline.
That would be a nice option, instead of being forced to loose bspline support in FC for dxf.
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Dxf Spline Export

Post by wandererfan »

easyw-fc wrote: Thu Jun 14, 2018 4:18 pm I know that R12 doesn't support splines
Then there is the option in case a spline is encountered, to let the exporter ask to convert spline to poly line or change the format to R14 at least to support spline.
That would be a nice option, instead of being forced to loose bspline support in FC for dxf.
Looks like the "legacy" dxf processor exports splines as polylines now, so I don't see how we're losing anything.

I've found specs for R14 and what I think is R24 (ACAD2010). Is there any point in trying to support all the intermediate versions or should the "modern" version be the newest I can find?
Attachments
FCSplineExp.dxf
(246.25 KiB) Downloaded 110 times
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Dxf Spline Export

Post by easyw-fc »

wandererfan wrote: Thu Jun 14, 2018 5:47 pm Looks like the "legacy" dxf processor exports splines as polylines now, so I don't see how we're losing anything.
We are loosing what we have gained with the macro to export the TechDraw Views
wandererfan wrote: Thu Jun 14, 2018 5:47 pm I've found specs for R14 and what I think is R24 (ACAD2010). Is there any point in trying to support all the intermediate versions or should the "modern" version be the newest I can find?
I would suggest an option to export as R12 or to switch to a modern way (2010)
jaisejames
Posts: 384
Joined: Sat Sep 24, 2016 6:51 am

Re: Dxf Spline Export

Post by jaisejames »

R12 to R13, there is coding style change required. Further ones are some feature addition only. If R14 is Ok to start with.

https://www.autodesk.com/techpubs/autoc ... reference/
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Dxf Spline Export

Post by easyw-fc »

wandererfan wrote: Thu Jun 14, 2018 5:47 pm Looks like the "legacy" dxf processor exports splines as polylines now, so I don't see how we're losing anything.

I've found specs for R14 and what I think is R24 (ACAD2010). Is there any point in trying to support all the intermediate versions or should the "modern" version be the newest I can find?
May be this lib can help ( ezdxf )
https://github.com/mozman/ezdxf/blob/master/README.rst
read/write/new support for DXF versions: R12, R2000, R2004, R2007, R2010, R2013 and R2018
additional read support for DXF versions R13/R14 (upgraded to R2000)
additional read support for older DXF versions than R12 (upgraded to R12)
preserves third-party DXF content
additional fast DXF R12 writer, that creates just an ENTITIES section with support for the basic DXF entities
jaisejames
Posts: 384
Joined: Sat Sep 24, 2016 6:51 am

Re: Dxf Spline Export

Post by jaisejames »

Current code

Code: Select all

    (*m_ofs) << "  0"          << endl;
    (*m_ofs) << "TEXT"         << endl;
    (*m_ofs) << "  8"          << endl;
    (*m_ofs) << layer_name     << endl;
    (*m_ofs) << " 39"          << endl;
    (*m_ofs) << 0              << endl;     //thickness
    (*m_ofs) << " 10"          << endl;     //first alignment point
    (*m_ofs) << location1[0]   << endl;
    (*m_ofs) << " 20"          << endl; 
    (*m_ofs) << location1[1]   << endl;
    (*m_ofs) << " 30"          << endl;
(*m_ofs) << location1[2] << endl;
need to change to

Code: Select all

    (*m_ofs) << "  0"          << endl;
    (*m_ofs) << "TEXT"         << endl;
    (*m_ofs) << "  5"          << endl;
    (*m_ofs) << "101"       << endl;  // continues counter [hex digit] say start from 101 for all table, block, entity  
    (*m_ofs) << "100"          << endl;
    (*m_ofs) << "AcDbEntity"   << endl;
    (*m_ofs) << "  8"          << endl;
    (*m_ofs) << layer_name     << endl;
    (*m_ofs) << "100"          << endl;
    (*m_ofs) << "AcDbText"     << endl;
    (*m_ofs) << " 39"          << endl;
    (*m_ofs) << 0              << endl;     //thickness
    (*m_ofs) << " 10"          << endl;     //first alignment point
    (*m_ofs) << location1[0]   << endl;
    (*m_ofs) << " 20"          << endl; 
    (*m_ofs) << location1[1]   << endl;
    (*m_ofs) << " 30"          << endl;
   (*m_ofs) << location1[2] << endl;
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Dxf Spline Export

Post by easyw-fc »

wandererfan wrote: Thu Jun 14, 2018 5:47 pm ... ...
I'm attaching a very simple example that will generate a wrong DXF because the view will produce splines.
dxf-splines.gif
dxf-splines.gif (174.38 KiB) Viewed 3005 times
project-view-splines.FCStd
(5.68 KiB) Downloaded 59 times
project-views-wrong.dxf
(4.69 KiB) Downloaded 113 times
the dxf will crash LibreCAD when trying to 'save as' the dxf file.
the same dxf will not be displayed correctly in DXF editors like DoubleCAD.
jaisejames
Posts: 384
Joined: Sat Sep 24, 2016 6:51 am

Re: Dxf Spline Export

Post by jaisejames »

It is working here. No crash librecad.

OS: Windows 7
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.18.13971 (Git)
Build type: Release
Branch: master
Hash: 8e4dd8ca8496595d4718dc24c872f7ed668b2521
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/India (en_IN)
Attachments
spline.dxf
(6.31 KiB) Downloaded 101 times
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Dxf Spline Export

Post by easyw-fc »

jaisejames wrote: Tue Jun 19, 2018 10:23 am It is working here. No crash librecad.

OS: Windows 7
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.18.13971 (Git)
Build type: Release
Branch: master
Hash: 8e4dd8ca8496595d4718dc24c872f7ed668b2521
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/India (en_IN)
you have a poly line not a spline on your dxf file... that is why it is not crashing
Post Reply