Grasshopper

algorithmic modeling for Rhino

I spent last month seeking the boundary of what can be done in GH and what can not be done in GH. 

a) If a GH component add a geometry to Rhino.RhinoDoc.ActiveDoc.Objects, it is not the handle of new object but a Guid is returned. If the new object is dragged and get a new position, the new position can be known via a request  with the Guid (ActiveDoc.Objects.Find(Guid g)). Then, the motion of the object added from the GH component can be tracked by the specified Guid.

b) If a GH component repeat a numerical procedure iteratively by using the Timer provided by GH and animate a geometry within Rhino.RhinoDoc.ActiveDoc.Objects, there looks no way of moving the geometry directly. A new object must be added and the old one must be removed. As the result, a new Guid will be returned. Direct access to the position of the geometry in Rhino.RhinoDoc.ActiveDoc.Objects seems to be  prohibited. Anyway, we can add geometries to Rhino and animate them from GH components without using GH preview feature.

c) But if an object is added and animated from a GH component, it is just a repetition of remove and add actions of the geometries so that the Guid changes step by step. Therefore, if an animated object is dragged, released and get a new position, the GH component can not catch the new position because it is the time after removing the dragged object.

Therefore, I feel that animating an object and tracking an object from a GH component are both OK, but their combination will cause a conflict. Is this understanding correct?

Views: 471

Replies to This Discussion

b) You can directly transform objects using:

Rhino.RhinoDoc.ActiveDoc.Objects.Transform()

if you pass in true for the deleteOriginal argument then the ID will remain the same. There's also:

Rhino.RhinoDoc.ActiveDoc.Objects.Replace()

which enables you to switch out the geometry inside a Rhino Object without changing the attributes.

All data inside the Rhino document is const and cannot be changed. The only way to 'change' an object is to delete the old one (which goes into the undo buffer) and adding a new one. This was done to bottleneck the document so have good control over what happens when. I.e. things never happen to objects in the document without us knowing about it.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks for reply.

OK, this behavior is due to the undo function so that there might be no hacking technique to move an internal object directly. Additionally, even if the same Guid is returned, the pointed object itself is internally a different object to the original one after a transformation, wright?

Actually, I tried both using Transform() and Replace(). I tried to manipulate x and y coordinate of an object inside Rhino from a GH component and, simultaneously, I tried to track z coordinate of the same object. However, when I drag the object, nothing happened. Then, I assumed the aforementioned internal behavior. Thanks a lot.

Indeed, you cannot change objects in the document. Use the guid to get a fresh instance of the document object after a replacement.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service