Hi,
The following code implements the attached GIF,
Option Explicit
Call Main()
Sub Main()
Dim i
For i=0 To 9
CageEdit(i)
Next
End Sub
Function cone
Dim strObject
strObject = Rhino.AddCone(array(0, 0, 0), array(0, 0, 20), 5)
cone = strObject
End Function
Function CageEdit(i)
Dim arrObjects,intcount
Dim strObj, arrPoints
Rhino.SelectObject cone
Rhino.Command("_CageEdit Boundingbox World XPointCount=2 YPointCount=2 ZPointCount=4 Enter Global Enter")
arrObjects = Rhino.LastCreatedObjects
intCount = Rhino.ObjectGripCount(arrObjects(0))
Rhino.print "The Number of Control Points is " & intCount
Rhino.SelectObjectGrip arrObjects(0), 0
arrPoints = Rhino.ObjectGripLocation(arrObjects(0), 0)
If Isarray(arrPoints) Then
arrPoints(1) = arrPoints(1) - i
Rhino.ObjectGripLocation arrObjects(0), 0, arrPoints
End If
End Function
How do I have access to the newly deformed cones in code? (E.g Store their volumes)
Is there a way to make the for loop from i=0 to intcount ? (The number of CageEdit Control Points)
like this: Sub Main() Dim i,intcount For i=0 To intcount mov(i,intcount) Next End Sub
How Do I break the long code line into two lines so that it fits in my portrait screen?
Specifically the line code addressing the Rhino.Command ("_CageEdit ....)
Thanks
You have the id for each cone, so you can access it. Below is an example on how to get and store the volumes and show them in a dialog once all cage edits have been done.
Note that i disable the redraw so it runs faster using Rhino.EnableRedraw vbFalse. In case of any aborts due to an error, you’ll need to hold your ESC key to get back. Test the script in an empty scene and notice the comments in the script.
Just create the cage in your function and get the number of control points so it can be used in your loop.
you can either pass the underlined characters to shorten that line:
Dim cmd
cmd = "_CageEdit B W X=2 Y=2 Z=4 _Enter _Global _Enter"
Rhino.Command cmd, False
or concatenate individual strings using multiple variables to your final command string eg.:
Dim a, b, c, cmd
a = "Hello "
b = "World "
c = "!"
cmd = a & b & c
Rhino.Print cmd
Many many Thanks to all your notes;
Regarding my second Question and your response:
That is what I tried to do in Function CageEdit(i) where intCount = Rhino.ObjectGripCount(arrObjects(0))
gets the number of CageEdit Control Points.
However I do not know how to take this data out from this function and use it in Sub Main() where I run the loop.
You might take a look into some tutorials on how to exchange values between functions and sub procedures. Best place is to start here, see the entry for VBScript Procedures.