converting parametric 2d curves and circles to polylines

Next
 From:  pior (PIOR_O)
10797.1 
Hello Michael and everyone,

When dealing with 2D CAD in the context of physical plotters (lasercutter/vinyl cutter) I often want to make sure that a design is exported in the most simple, barebones way possible so that there are no surprises when interfacing with the software of the machine. For instance some of them may not be able to properly process a parametric circle or an interpolated curve.

While exporting to DXF is a good bruteforce way of doing things, it still leaves some parametric components (circles in particular). I just had the case recently with a vynil cutter software not processing a round cut that I had to eventually redraw as a polygon.

Is there a way to do such conversion directly in MOI ? A curve rebuild of sorts but without any interpolation handles, just segments. Like so (third picture) :



Thanks !

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10797.2 In reply to 10797.1 
https://moi3d.com/forum/index.php?webtag=MOI&msg=10719.1

I forgot that reconstruct does this.

- Brian

But it is also cutting up straight lines.
So maybe run separate first?
Reconstruct curved curves, and then join back up?

Maybe the script could be re-written to do this?

EDITED: 1 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10797.3 In reply to 10797.2 
This link might be helpful, for further work:

https://moi3d.com/forum/index.php?webtag=MOI&msg=8010.1
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10797.4 In reply to 10797.1 
Hi pior, by default the DXF export will create a LINE, CIRCLE, or ARC entity in the exported DXF file if the curve in MoI matches those types.

You can disable that by a setting in moi.ini :

[DXF Export]
<...>
UseSimpleEntities=y

If you set UseSimpleEntities=n then it will write circles as polylines or splines depending on the "Write curves as:" option in the export dialog.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  blowlamp
10797.5 
You could also overlay or replace the circles with polygons to get what you're after.

Martin.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pior (PIOR_O)
10797.6 
Thank you all for the suggestions.

@Michael : indeed that works great - with UseSimpleEntities=n, all the problematic elements that the cutter software wasn't seeing are now properly imported. Perfect :)
Is there any way to have this is part of the export settings, so as to not have to tweak the ini each time ?

Also, is there any way to perform this kind of conversion without having to even export/reimport at all (that is to say, getting to the result from within the work scene) ?

@Blowlamp : well this approach works to an extent, and I have been doing exactly that when needed ... but is not sustainable when having to redraw all the through holes of a design :) And moreover, one could end up missing some important parts.

@Bemfarmer : I'll definitely have to try this idea too, thanks !

EDITED: 2 Aug 2022 by PIOR_O

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10797.7 In reply to 10797.6 
Hi Pior,

re:
> Is there any way to have this is part of the export settings, so as to not have to
> tweak the ini each time ?

I'll see about adding it to the DXF export options dialog.


> Also, is there any way to perform this kind of conversion without having to even
> export/reimport at all (that is to say, getting to the result from within the work scene) ?

You could use the ReconstructCurve script that Brian wrote about above.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10797.8 In reply to 10797.6 
Hi Pior,

I would say that Michael's answer is the best and quickest to export the desired type of objects.

But if you wanted to separate your curves, and run reconstruct only on say "arcs", and keep the line segments as lines:

As of MoI4, there is a curve property to see if the curve is a line:

crv.isLine - Property that returns true if the curve has the shape of a line.
https://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1429

So if separate is done on the rounded rectangle, the curves that are lines can be separated out, and kept as lines.
The arc's can have reconstruct curve applied to them, to make them polylines.
Then rejoin the original straight lines, and the new polylines.
This is a very bare bones outline of a script.
The required polyline desire should be described in detail.
Which curves are to get turned into polylines.
Polyline length/numpoints.
etc...

So maybe a script could be written that would do this?
At this time, I do not have the time to attempt a script.

There are other curve properties listed in the link.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10797.9 In reply to 10797.8 
Hi Brian, also you can select arc and circle curves in v5 using the Scene Browser:





- Michael

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10797.10 In reply to 10797.9 
Great suggestion on the new curve types "menu"

So the reconstruct could be done manually, with help from MoI5. (?)

Something like:
Hide existing lines and polylines.
Apply reconstruct to arcs and ellipses and whatever other curve types.
Nothing gets missed...

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10797.11 In reply to 10797.9 
Just for general information, I'll have to learn how the curve types work, in the scene browser.
What gets hidden,
What gets unhidden
...

-Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pior (PIOR_O)
10797.12 
Between the UseSimpleEntities flag and the special ReconstructCurve script from https://moi3d.com/forum/index.php?webtag=MOI&msg=10719.1, I believe I have pretty much everything I need to address this scenario.

I am still a bit confused by the DXF export dialog though - shouldn't the DXF export be made of polylines if the user choses so in the export options, regardless of the state of UseSimpleEntities(y/n) in the .ini ?



So perhaps this panel needs some clarifications as to what the options do and do not do, and the relationship with the UseSimpleEntities flag ...

- - - - -

[Edit] : Oh OK I think I get it now. If a part has corners made out of circle sections (that is to say, perfectly round fillet corners), this part will indeed export out as polyline if the DXF exporter option is set to Polyline *and* if the whole thing is combined and connected before export. But if the part is made out of multiple detached bits before export, then the circle sections of the filleted corners will be recognized as such ... and therefore these circle segment curves will not be exported as polylines (except if the are forced to do so when UseSimpleEntities = n).

I understand that this "makes sense" once one knows about the concept of SimpleEntities, but I must say this is far from intuitive and would indeed benefit from some explanation text in the export dialog ...

EDITED: 7 Aug 2022 by PIOR_O


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10797.13 In reply to 10797.12 
Hi Pior, the way it works is if UseSimpleEntities=y (which is the default), then if a curve is a line, circle, arc, or polyline it will be written as a LINE, CIRCLE, ARC, or POLYLINE entity type in the generated DXF file.

If it does not get written as one of those specific entity types (either because UseSimpleEntities=n or if it is not a line, circle, arc, or polyline) then it will be processed as a general curve and will use the processing specified in the dialog for "Write curves as", either writing a SPLINE entity or converting it to lines and writing a POLYLINE entity.


> I am still a bit confused by the DXF export dialog though - shouldn't the DXF export be made
> of polylines if the user choses so in the export options, regardless of the state of
> UseSimpleEntities(y/n) in the .ini ?

No, because if it worked like that then UseSimpleEntities would not do anything and there wouldn't be any way to write LINE, CIRCLE, or ARC entities.

If you want everything to be written as polylines, then set UseSimpleEntities=n in moi.ini and you should not get any LINE, CIRCLE, or ARC entities being written anymore.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pior (PIOR_O)
10797.14 
Hello ! Indeed - I figured it out and appended my previous post ... probably just as you were typing your reply :D

All that said, since the behavior of selecting "polylines" in the export dialog is indeed dependent of the state of UseSimpleEntities, then I would say that this does require for the flag to be switchable in the export options indeed as briefly mentioned above - especially since one would assume intuitively that a "circle segment/arc" is a subset of the group "curve" ... even though in the DXF sense they are distinct separate entities.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10797.15 In reply to 10797.12 
Hi Pior,

re:
> [Edit] : Oh OK I think I get it now. If a part has corners made out of circle sections (that is to say,
> perfectly round fillet corners), this part will indeed export out as polyline when the exporter
> option is set to that *if* the whole thing is combined and connected.

If you have a curve that started out as a rectangle and then had corners filleted, then that whole curve is not a line, circle, arc, or polyline and so will not be processed as one of those entities, it will go through general curve handling.

If you use Edit > Separate to break the joined curve into separate smaller curves then you will have 4 lines and 4 arcs and so in that case if UseSimpleEntities=y it will write those out as LINE and ARC entities.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
10797.16 In reply to 10797.14 
Hi Pior,

> since one would assume intuitively that a circle segment is a subset of the group "curve" (even though in the DXF sense they are different entities).

The term "Curve" in MoI terminology has a specific meaning, it's a wire object that has a child list of Curve Segments.

An arc that is contained inside a parent curve is not a "Curve" in MoI, it's a "Curve Segment".

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All