Author Topic: Flatten STEP file to SVG script  (Read 2291 times)

Offline nm156

  • Ewok
  • *
  • Posts: 23
    • View Profile
Flatten STEP file to SVG script
« on: September 11, 2024, 04:15:33 am »
Started a new topic in this section to upload the completed script. 
Thanks to dh42 for his assistance with this!

The script waits for STEP files from a  CAD source (tested with Alibre) to saved  to the LISTENDIR.  It then imports the file   and  flattens it into 2D using the face that  is largest on the XY plane with respect to CamBam.  The resultant vectors are output  using the SVG export plugin.

The assumption is that parts imported are 2 dimensionally flat on the XY plane to be laser cut or milled with 2D profiles.

Edit:  Update to current script version

Paul
« Last Edit: September 13, 2024, 12:17:52 pm by nm156 »
machines have no conscience

Offline nm156

  • Ewok
  • *
  • Posts: 23
    • View Profile
Re: Flatten STEP file to SVG script
« Reply #1 on: September 13, 2024, 12:28:46 pm »
Yeah, the forum is stable again!

Sorry David for starting this new topic.  I thought the script was ready for primetime.

The attached (first post this topic) script does work for the included test cases, but still is feature incomplete.

This started out to be a quick fix script and I ran down a rabbit (rab-bot?) hole.
So this script works, but not with all STEP files yet.
 
Background
1. All shapes must be closed, internal and external. Otherwise it won't nest or appear as separate objects.
2. Importing a STEP file creates un-joined primitives, but does create true Circles. For nesting use all shapes must be closed, internal and external.
3. Silhouette created circles are not true circles, but it does close primitives.

The attached code looks convoluted because:

1. - Silhouette created circles are not true circles (Polyline and Arc). Even when the source is a Circle.
2. - I have to identify and compare arcs to true circles
3. - Specific checks must be made to check for intentional 'D' shaped objects as per first item
4. + Polylines are joined correctly with Silhouette
5. - I now need to check for two arcs that close to form a circle (not going to assume they are each 180 degrees, but are likely) 

Should I continue down this path, or re-evaluate the process entirely and find a better method?

Paul

machines have no conscience

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7422
    • View Profile
    • Cambam V1.0 French Doc
Re: Flatten STEP file to SVG script
« Reply #2 on: September 13, 2024, 17:46:35 pm »
Hello

Quote
1. - Silhouette created circles are not true circles (Polyline and Arc). Even when the source is a Circle.

Silhouette works only on meshes, so because the STEP files are converted to mesh surfaces when imported in CamBam, you necessary get segmented 2Dshapes as on a STL file even if it was a circle in the STEP file.

A know problem is with the "arcfit" function that can be applied on a "circle like" segmented shape ; when used on a circular shape made from straight segments, only the segments defined into the collection of points of the polyline are converted to arcs, but the last one, that is added between the last and the first point of a polyline when it is marked as closed is never replaced by an arc and remain as straight line. Maybe it is the problem you encounter ; did you have an arcfit somewhere in the code ?



++
David
« Last Edit: September 13, 2024, 17:49:34 pm by dh42 »