Hi,
What I am trying to do in the following code is to deform an extruded Object (Polygon Based) by means of History Recording. That means any upcoming changes to the polygon results in the deformation of the extrusion as well. However, unlike the the initial polygon, the extruded surface maintains it previous form.
Any ideas what is missing?
Thanks in advance;
Here is the Code:
Call Main()
Sub Main()
Dim strObject,cpoint,m,intcount
strObject = Rhino.addPolygon(rhino.WorldXYPlane, 10, 6)
If Not IsNull(strObject) Then
Rhino.EnableHistoryRecording True
Rhino.EnableObjectGrips strObject
Rhino.ExtrudeCurveStraight strObject, array(0, 0, 20)
m = Rhino.ObjectGripLocation(strObject, 5)
m(0) = m(0) + 5
m(1) = m(1) + 0
m(2) = m(2) + 0
Rhino.ObjectGripLocation strObject, 5, m
End If
End Sub
Rhino’s History history is command-based. That is, History-enabled commands store the connection between a command’s input geometry and the result so that when the input geometry changes, the result updates accordingly.
Being that History is command-based, it is not possible for a script to participate in History (other than to enable or disable its recording).
If you were to do the above in just Rhino, it would be the ExtrudeCrv command that would be recording the input history. So you might consider scripting this command using Rhino.Command.
@dale
Thanks for the note
But…
since I want to run it by code
I am still Confused.
Could you please be more specific about the Rhino.Command ?
I know how to apply it on “Commands” not in “Tabs” such as Gumball, Record History or Grid Snap
@Vahab, try the example below, then move the polygon in rhino to see history update:
Option Explicit
Call Main()
Sub Main()
Dim arrPlane, strObject, dblDistance, strCmd
arrPlane = Rhino.WorldXYPlane()
strObject = Rhino.AddPolygon(arrPlane, 10, 6)
If IsNull(strObject) Then Exit Sub
Rhino.EnableHistoryRecording True
Rhino.SelectObject strObject
dblDistance = 20.0
strCmd = "_ExtrudeCrv _Solid=Yes " & dblDistance
Rhino.Command strCmd, False
End Sub
Note that i just used a extrusion distance as variable dblDistance. You can feed a direction vector as well using the _Direction option of the _ExtrudeCrv command if required.
Note that arrPoint is an array not a string. Commandline inputs are strings, so you’ll need to convert your point to a string to use it via Rhino.Command:
vbscript does have a built in Join method which you can use as well. It allows to control the separator. If it is not defined a space is used, below is using a comma eg.:
Dim a, seperator
a = Array(1,2,3,4,5)
Rhino.Print "Result: " & Join(a, ",")
should print like below
Result: 1,2,3,4,5
The Rhino.Pt2Str method does basically the same, but offers a few more options for the precision and a trailing space, perfect to pass multiple 3d points to the commandline. You can find more about in the Utility methods section of the helpfile: