Use String from another Sub



Those any one know how to call a String obtained by another function?

I created some planes in a Sub, now on other Sub I want to call that plane to use for intersection.
Problem is I don’t know how to reference the string in a different Sub

for exemple

Call Planes

Sub Planes
Dim point1, point2, point3, point4, Plane1

point1 = rhino.addpoint(0,0,0)
point2 = rhino.addpoint(10,10,0)
point3 = rhino.addpoint(-10,-10,0)
point4 = rhino.addpoint(-10,10,0)

plane1 = rhino.addsurface(point1, point2, point3, poin4)
End Sub

Call section

sub section
dim Plane1

How do I call the Plane1??

thanks everyone
will help me alot organize this script which is all in 1 Sub :slight_smile:

(Pascal Golay) #2

Hello- instead of making the plane in a sub, make it a function that returns the plane as its result:

Function MakePlane()
blah blah
MakePlane = rhino.addsurface(point1, point2, point3, poin4)

End Function

Sub Section

dim Plane1: Plane1 = MakePlane()

end sub



Nice, thanks.

Can I make more then 1 plane per function? how do I then call a specific plane then?
Or is just better to do 1 plane per function?

(Pascal Golay) #4

You can make an array of planes and then access the array by index.

So, your function would build up an array

Function MakePlanes(Num)
dim i, arrPlanes
redim arrPlanes(num-1)

for i = 0 to num-1

blah blah

arrPlanes(i) = rhino.addsurface(point1, point2, point3, poin4)


MakePlanes= arrPlanes
End Function

Sub Section
dim aPlanes: aPlanes = MakePlanes(5)

dim Plane1: Plane1 = aPlanes(0)
dim Plane2: Plane2 = aPlanes(1)
etc etc

End Sub



Cool, I see

Will give it a go, thanks so much for your help.
As always you guys kick ass!!! :slight_smile: