DXFNext

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: DXFNext

Post by onekk »

Gift wrote: Thu Jun 16, 2022 11:33 am Polylines (and lwpolylines)

Part & Draft are supported. Polylines are split in the Part module to lines. If someone knows how to use a spline (one degree) here, please let me know.

Why directly wires, or polygons, it would not be too difficult to extract points and pass them to a wire entity or maybe directly to a Part.makePolygon

if you have already Part.LineSegments a lwpolyline could be made simply with:

Code: Select all

wire = Part.Wire("list of lines")
Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Gift
Posts: 769
Joined: Tue Aug 18, 2015 10:08 am
Location: Germany, Sauerland

Re: DXFNext

Post by Gift »

onekk wrote: Mon Jun 27, 2022 5:09 pm Why directly wires, or polygons, it would not be too difficult to extract points and pass them to a wire entity or maybe directly to a Part.makePolygon

if you have already Part.LineSegments a lwpolyline could be made simply with:

Code: Select all

wire = Part.Wire("list of lines")
Regards

Carlo D.
With Part.LineSegments or Part.makePolygon we lost information that it is a polyline. If you create polyline in LibreCAD, load it in FreeCAD, save it and load in LibreCAD again you will get separates lines and not one polyline. So my idea is to create simple spline.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: DXFNext

Post by onekk »

Not if you state that a wire or a polygon is translated in a lwpoly when output as dxf.

I have done in the past a similar thing for a cam program that used polylines.

A polyline is simply some segmentes (lined) joined closed or not.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Gift
Posts: 769
Joined: Tue Aug 18, 2015 10:08 am
Location: Germany, Sauerland

Re: DXFNext

Post by Gift »

onekk wrote: Mon Jun 27, 2022 6:38 pm Not if you state that a wire or a polygon is translated in a lwpoly when output as dxf.

I have done in the past a similar thing for a cam program that used polylines.

A polyline is simply some segmentes (lined) joined closed or not.

Regards

Carlo D.
How do I know that the user has created a polyline, or by chance two lines meet.

Code: Select all

wire = Part.makePolygon([App.Vector(0, 10, 0), App.Vector(0, 0, 0), App.Vector(10, 0, 0)])
wire.Edges
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: DXFNext

Post by sliptonic »

Gift wrote: Mon Jun 27, 2022 4:53 pm I have tested the Ezdxf library. Which needs only to read the following file 80 seconds. My solution needs 33 seconds to read, create the objects and render. The first two steps run parallel. I think performance is an important feature. If you see other aspects in the foreground, we should create a morphological analysis.
Of course performance is important. So is reliability. Have you tested your solution with the full range of possible DXF files and features?

DXF conversion is usually only done once, not on every recompute. So a solution that takes 80 seconds but can reliably handle a vast array of input is superior to one that takes 33 seconds but is limited to a subset of DXF files. No?
User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: DXFNext

Post by wandererfan »

Gift wrote: Mon Jun 27, 2022 4:53 pm n short, I have tested the Ezdxf library. Which needs only to read the following file 80 seconds.
This is my selfish perspective, so apply salt liberally...

Reading is to some extent the easy part of dealing with Dxf - you only have to read the interesting parts and ignore the rest.

The hard part is writing so other software will accept the file without complaints and this is where a dedicated library will score points.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: DXFNext

Post by onekk »

Gift wrote: Mon Jun 27, 2022 7:03 pm How do I know that the user has created a polyline, or by chance two lines meet.

Code: Select all

wire = Part.makePolygon([App.Vector(0, 10, 0), App.Vector(0, 0, 0), App.Vector(10, 0, 0)])
wire.Edges

if the user has a Draft.Wire or a Part.Wire, it has to be translated to lwpoly in DXF, when a user create a Wire, he wants that lines will "stay together" even in the DXF file.

same as in DXF if a user has created a polyline, I think that even in FC these lines have to "stay together"

Probably I'm wrong, but I don't see where is the problem?

In the CAM I'have used when I create a profile in LibreCAD, and saved it in DXF it is imported as a polyline in the CAM software.

Same the inverse, polylines in the CAM where exported as single entities in the DXF single lines have their own "object".

I haven't used it frequently in last times, but this behaviour seems pretty "natural".

I admit that I have not readed DXF specifications, so probably I'm wrong.

If this is the case, I apologize.

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Gift
Posts: 769
Joined: Tue Aug 18, 2015 10:08 am
Location: Germany, Sauerland

Re: DXFNext

Post by Gift »

sliptonic wrote: Mon Jun 27, 2022 7:21 pm ... So is reliability. Have you tested your solution with the full range of possible DXF files and features? ...
The statement on the page to this topic is somewhat schizophrenic or modest. The praser is one element. The best library is no guarantor for the best product. I have searched for files that are problematic. E.g. from bugs reports. Every example is welcome.

sliptonic wrote: Mon Jun 27, 2022 7:21 pm ... DXF conversion is usually only done once, not on every recompute. So a solution that takes 80 seconds but can reliably handle a vast array of input is superior to one that takes 33 seconds but is limited to a subset of DXF files. No? ...
80 seconds for the prasing and then you get an object list from which the FreeCAD objects must be created. Then you have to join them together. That means we are more likely 120 seconds vs 33 seconds.

I see no reason for a limited subset. The biggest barrier is the interface. For example, the current C++ solution has some limitations to 2D and do not support 3D. I have removed these. But this has nothing to do with reading the file.

I would like to find a consensus. Maybe a fork with the translation to C++? What is your vision? Not just a library or a name. A destination.

wandererfan wrote: Mon Jun 27, 2022 8:51 pm The hard part is writing so other software will accept the file without complaints and this is where a dedicated library will score points.
That's a strong argument. See the last 4-5 sentences at the previous reply.
User avatar
Gift
Posts: 769
Joined: Tue Aug 18, 2015 10:08 am
Location: Germany, Sauerland

Re: DXFNext

Post by Gift »

onekk wrote: Tue Jun 28, 2022 8:30 am
if the user has a Draft.Wire or a Part.Wire ...

...
That is your postulate. Internally there is no Part.Wire. That is a function, which create edges. Inspect the result of the script.
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: DXFNext

Post by sliptonic »

Gift wrote: Tue Jun 28, 2022 7:31 pm
I would like to find a consensus. Maybe a fork with the translation to C++? What is your vision? Not just a library or a name. A destination.
I can't say that I have a vision or destination in mind. I'm thinking more about basic ideas like those in Raymond's 17 rules. Specifically "Value developer time over machine time"

If someone else has committed years to become expert working with DXF and is licensing their work in a compatible way, then we should need a VERY compelling reason not to use. it. Otherwise our bug reports and improvements don't benefit librecad, kicad, Brl-CAD or anyone else and we don't get the benefit of theirs.

Of course if you want to work on this, that's fantastic. I'm grateful. OTOH, if the issue is speed, why not strive to make ezdxf faster?
Post Reply