Extrude Surface to Point in RhinoScript


#1

Hello,
I wonder if there is a bypass to code Extrude Surface to Point in RhinoScript using Rhino.AddPlanarSrf.
The current code I am using is a little bit frustrating:

Option Explicit

Call Main()
Sub Main()

Dim arrInput0, arrInput1,strObject0,strObject1,surface1,surface2
Dim arrLst1(), arrLst2()
Dim i,j	
i = -1
j =-1

arrInput0 = Rhino.GetObjects("Select inner Curves")

ReDim arrLst1 (Ubound (arrInput0)) 

Rhino.EnableRedraw(False)

If IsArray(arrInput0) Then

	For Each strObject0 In arrInput0
		i = i + 1
		surface1 = rhino.ExtrudeCurvePoint(strObject0, array(0, 0, -20))
		rhino.CapPlanarHoles(surface1)
		arrLst1(i) = surface1
	Next
	
	arrInput1 = Rhino.GetObjects("Select bounding Curves")
	ReDim arrLst2 (Ubound (arrInput1)) 
	
	If IsArray(arrInput1) Then
			Rhino.EnableRedraw(False)
		For Each strObject1 In arrInput1
			j = j + 1

			surface2 = rhino.ExtrudeCurvePoint(strObject1, array(0, 0, -20))
			rhino.CapPlanarHoles(surface2)
			arrLst2(j) = surface2				
		Next
					
	End If
	Rhino.BooleanDifference arrLst2, arrLst1
	
End If

Rhino.EnableRedraw(True)

End Sub

#2

what is your Problem ? what is not working well ?
the BooleanDifference at the end ?

Maybe there should be an offset in the z-height of the tip ?


surface1 = rhino.ExtrudeCurvePoint(strObject0, array(0, 0, -15))

surface2 = rhino.ExtrudeCurvePoint(strObject0, array(0, 0, -20))


#3

@Tom
The code is working properly,
However you have to be precise to take inner curves first and then the outer curves, rather than drag a window over all curves to select them all.
For Example, The following code does almost the same with straight extrusion,
You can take all the curves at once:

Option Explicit

Call Main()
Sub Main()

Const rhObjectCurve = 4

Dim arrObjects,i,b,strCurve
strCurve = Rhino.AddLine(array(0, 0, 0), array(0, 0, 20))

arrObjects = Rhino.GetObjects("pick to extrude", rhObjectCurve)

If IsArray(arrObjects) Then

	b = Rhino.AddPlanarSrf(arrObjects)

End If
For Each i In b
	Rhino.ExtrudeSurface i, strCurve
Next


End Sub

#4

Rhinoscript’ s Rhino.PlanarClosedCurveContainment
might help you
Or you use Rhino.AddPlanarSrf - and then use DuplicateSurfaceBorder twice - once for inner - once for outer curves

Dim crvsInner, crvsExterior
crvsExterior = Rhino.DuplicateSurfaceBorder(i,1)
crvsInner = Rhino.DuplicateSurfaceBorder(i,2)

The similar to your old script…
Then build one Volume for the exterior Curve, and multiple for the Inner Curves.
Then a Volume for each Inner Curve…
Bool…