Extrude multiple Curves at the same time

rhinoscript

#1

Hello All,
As you know the following code implements one curve to extrude:

Dim strobject,strPath
strobject = rhino.GetObject(“select a curve to extrude”)
strPath = Rhino.AddLine(Array(0, 0, 0), Array(0, 0, 10))
rhino.ExtrudeCurve strobject, strPath

What if multiple curves are to be extruded?
I simply tried this:

Dim strobjects,arrobjects
strobject = rhino.GetObjects(“select curves to extrude”)
strPath = Rhino.AddLine(Array(0, 0, 0), Array(0, 0, 10))
rhino.ExtrudeCurve strobjects, strPath

Here is the Error: Type mismatch Parameter, String Required.
Thanks In advance :slight_smile:


#2

@Vahab,

Rhino.ExtrudeCurve expects a single curve. To extrude multiple curves, you might try using the method in a loop and extrude each of the curves:

Option Explicit

Call Main()
Sub Main()
    
    Dim arrObjects, strObject, strPath
    
    arrObjects = Rhino.GetObjects("Select curves to extrude", 4, False, True)
    If IsNull(arrObjects) Then Exit Sub
    
    strPath = Rhino.AddLine(Array(0, 0, 0), Array(0, 0, 10))
    For Each strObject In arrObjects
        Rhino.ExtrudeCurve strObject, strPath
    Next

End Sub

c.


#3

As your strPath is just a straight line , you can also use Rhino.ExtrudeCurveStraight to avoid this line construction.

Option Explicit

Call Main()
Sub Main()
    
	Dim arrObjects, strObject	
   
	arrObjects = Rhino.GetObjects("Select curves to extrude", 4, False, True)
	
	If IsNull(arrObjects) Then Exit Sub
	
	Rhino.EnableRedraw(False)
	
	For Each strObject In arrObjects		

		Rhino.ExtrudeCurveStraight strObject, Array(0, 0, 0), Array(0, 0, 10)

	Next
	
	Rhino.EnableRedraw(True)

	
End Sub

#4

Thank you so much :slight_smile:


#5

Thanks buddy,
That is indeed a good point to consider,