GH or GH/Python: Manipulate existing Rhino document objects...?


#1

Hi all,

I’m just wondering if it’s possible to execute some simple transformations (move, rotate) on existing objects in a Rhino document referenced in GH… I know I can do stuff in GH and then bake new ones, but in this case, the objects need to retain all of their original characteristics, ID’s, layers, applied materials, etc…

All this can be done with a normal Python script outside of GH, but this particular project is sufficiently complex that I would like an interactive preview to set things up the way the user wants, then set the changes. I was thinking that all the relevant stuff could be done with normal GH components and a custom preview, then when everything is set, send the transformation data into a Python component and have it apply the transformations (once) to the objects in the document…

Possible? Pipe dream? Going down a wrong-way street here? I don’t know enough about GH and its relation to existing RhinoDoc objects to figure it out on my own yet…

Thanks, --Mitch


(Giulio Piacentino) #2

Hi Mitch

if I am understanding what you are asking, in part this is possible.
One part, I think, concerns applying rhinoscriptsyntax with the right document as target. This is supported. See this post for an example.

The “once” part might prove a bit more difficult (how are you going to handle the “undo” properly? Will you keep a “shadow copy”? The latter would be my choice.

I hope this helps

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#3

Hi Giulio,

Thanks for the response… I will attempt to make a mockup of what I want to so with some simple objects and see how far I get… Undo… hmmm, that I hadn’t considered, I guess there is no method for adding the transformation to the normal Rhino undo stack…

Cheers, --Mitch


(Giulio Piacentino) #4

Operations you do from Python will be recorded in the Undo stack. But you cannot simply undo, as maybe the user will have done something between your original operation and your need to undo.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


(Luis Fraguada) #5

Mitch, Checkout the RhinoObject class: http://4.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_DocObjects_RhinoObject.htm

Specifically the CommitChanges method: http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_DocObjects_RhinoObject_CommitChanges.htm

I used this before to do what you are saying.


#6

Try this. I think that’s what Giulio meant, when he said “shadow copy” too.

rhino_grass_rhino.3dm (27.6 KB)

rhino_grass_rhino.gh (13.7 KB)