Looks great !! So if I have to make other shapes can I just use this file and enter other shapes in the layers scr-top, stringer and step with an import dxf and run the scripts ?
Sort of, here are some general guidelines...
'src-top' layerThe script in the top of the drawing contains two lines...
arc1 = doc.FindPrimitive(60)
arc2 = doc.FindPrimitive(58)
So if those two arcs get replaced, the IDs will also need to be updated in the script.
It may be easier just to hard code in the radius like this...
radius1 = 212.5
radius2 = 157.5
Then the 'src-top' layer isn't needed at all and can just be used for reference.
'stringer' layerEach edge segment must be a single polyline. I did this by using edit 'explode' on your source drawing, selecting all the shapes in one edge, then using edit join.
...or just ctrl+p to turn the line segments back into polylines.
The left hand edge needs to be aligned on the Y axis. The Transform - Move command (CTRL+M) is handy for this. If you hold down the CTRL key when selecting the source points you can select 2 source points on one edge, then line them up when selecting destination points.
'step' layerAgain, each edge segment must be a single polyline.
I also needed to trim the lower step that you had drawn overlapping the stringer shape.
wrap_edges and
surface_wrapsThese should automatically update if the top level script changes or when the document is reopened.
Otherwise you can highlight all the scripts and press 'F5' to update.
I have just added a script as the first object in the drawing tree, with 'Execute on Update' set 'False' and code...
doc.UpdateChildScripts(True)
Selecting this script and pressing F5 will then refresh all the scripts in the drawing.
Now things get a bit more tedious sorry!
'wrap_edges_exploded'Select the script in 'explode_wrap_edges_F5' layer and press 'F5'.
This will replace all the edges in the 'wrap_edges_exploded' layer with the recalculated edges from 'wrap_edges'
Unfortunately, this means all the following scripts that used the IDs of these edges will now need to be manually updated.
There are also 4 line segments in layer 'manual_edge_draw' that will need to be updated.
Probably easier just to double click the existing ones and drag the end points to the updated positions.
(I was planning to automate those but ran out of time)
'manual_surfaces' layerThe first script in this layer (script 165) has the following code
(I've added some comments to identity which sections do what)
# top step pocket edges
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([134,78,133,94],False))
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([133,81,138,97],True))
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([138,80,136,96],True))
# middle step pocket edges
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([82,141,98,142],True))
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([141,85,146,101],True))
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([146,84,144,100],True))
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([144,83,142,99],True))
# bottom step pocket edges
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([150,86,149,102],False))
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([154,92,152,116],True))
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([152,87,150,103],True))
# left hand edge
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([158,170,134,95,136,171,159,132],True))
# right hand edge
this.Entities.Add(SurfaceFiller.PlaneFillPolylineSegs([157,131,160,169,154,124,149,168],True))
The numbers are the IDs of the polylines that make up the boundaries of those faces.
I found it easier to have a copy of the script open in another program (such as notepad), then click on the edges in the drawing for each boundary and type in the ID
into the corresponding script.
If a surface looks grey, you may need to reverse the True/False parameter to invert that surface.
The other two scripts in this layer create the top and bottom swept surfaces.
The code for the top one is...
# front edge
polyA = doc.FindPrimitive(125)
# rear edge
polyB = doc.FindPrimitive(129)
this.Entities.Add(SurfaceFiller.BridgeFillPolylines(polyA,polyB,True))
'all_surfaces' layerOnce all the manual surfaces have been updated, you can refresh the script in this layer.
Hide all the layers other than this one, then export the file to an STL.