Extrude Closed Curves with Holes, Solid with One window Selection


#1

Hello,
Can anyone please help with this?
sub ExtB in this code takes curves with some closed curves inside them and simply makes them extruded and solid.
Having attempted to avoid Rhino.Command as much as possible, I wrote Sub ExtA.
It does not seem to be efficient as it is currently working on 4 curves only.

Here is the code:

Option Explicit
Call Main()
Sub main()
    ExtA
    ExtB
End Sub

Sub ExtA
    Dim arrObjects,strObject,strExt
    Dim arrLst()
    Dim i
    i = 0
    arrObjects = Rhino.GetObjects("Pick curves")
    If Not IsNull(arrObjects) Then
	    ReDim arrLst (Ubound(arrObjects))
	    For Each strObject In arrObjects	
		    strExt = Rhino.ExtrudeCurveStraight(strObject, array(0, 0, 20))
		    Rhino.CapPlanarHoles strExt
		    arrLst(i) = strExt
		    i = i + 1
	    Next
    End If
    Rhino.BooleanDifference arrlst(0), arrLst(1)
    Rhino.BooleanDifference arrlst(2), arrLst(3)
End Sub

Sub ExtB
    Dim arrObjects
    arrObjects = Rhino.GetObjects("Pick curves")
    Rhino.SelectObjects arrObjects
    Rhino.Command "ExtrudeCrv S=Yes 20"
    Rhino.UnselectAllObjects
End Sub

#2

@Clive,

you could do this without booleans if you create planar surfaces from your nested curves first and then extrude them along a path:

Option Explicit

Call Main()
Sub Main()
    
    Dim arrCurves, arrSurfaces, strPath, strSrf

    arrCurves = Rhino.GetObjects("Select planar curves to extrude", 4, True, True)
    If IsNull(arrCurves) Then Exit Sub
    
    arrSurfaces = Rhino.AddPlanarSrf(arrCurves)
    If IsNull(arrSurfaces) Then Exit Sub
    
    strPath = Rhino.AddLine(Array(0, 0, 0), Array(0, 0, 20))
    
    For Each strSrf In arrSurfaces
        Rhino.ExtrudeSurface strSrf, strPath, True
    Next

    Rhino.DeleteObject strPath

End Sub

does that help ?

c.


#3

@clement
Yeah, thanks
But I also would like to know if my own code would be working by any chance.
Even if it was not efficient as yours.


#4

The problem is, your script has no way of telling the difference between curves that are inside and curves that are outside. So if you grab them all at once, it’s virtually impossible to know what to subtract from what. Two ways to solve the problem - one would be to check all the curves and find which ones are inside which others, create a list of sets of curves which go together, loop through the list, extrude and subtract. But that’s time consuming and far less robust than what Clement suggested.

–Mitch


#5

@clement
@Helvetosaur
I noticed there is not any Syntax in RhinoScript for “Extrude Surfaces to Point”.
In that case, does it make sense to make surfaces by Rhino.AddPlanarSrf just like what Clement suggested and then by Rhino.ExtrudeCurvePoint make the outline of the surfaces extruded to a point and finally join all surfaces together?


#6

@Clive,

yes, in case of nested curves this would be the easiest way since you do not have to figure out which curves are inside other curves. To get the borders of the arrSurfaces defined in my last example above just use

Rhino.DuplicateSurfaceBorder

then extrude these curves to a point and join the result with each initial surface.

c.


#7

Many Thanks :slight_smile: