Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5894

Moving grips with python

$
0
0

Hello all,

I’m rather new to python and rhino scripting, please bear with me.

I want to let the user select and move any type of object including grip in a certain direction, using python. I figured that rs.GetObjects ignores grips, so I’m doing the objects input like this :

objs = rs.GetObjects( "my-prompt", filter=2013524799, preselect=True )

Where 2013524799 is a bitwise OR of all the geometry filters.
So in objs I successfully have any type of objects including grips. I want to translate each of these objects, but if I move them like this :

for obj in objs:
    rs.MoveObject( obj, vector )

points, curves and surfaces are moved properly but grips are ignored. What is the reason for that ? Is there anything I can do using rhinoscriptsyntax ? It would have been a breeze…

Digging for a workaround I’ve read this related post from Dale Fugier. However I had a rough time with this solution, because I want to move the grips and redraw at runtime. scriptcontext.doc.Objects.GripUpdate will update the grip, but either I set its deleteOriginal argument to False and the objects are duplicated many times along the translation, either I set it to True, and nothing happen, I assume because the grip is removed from the TransformObjectList. I tried to add the new object returned by GripUpdate to the TransformObjectList, but it doesn’t seem to work.

Is there an easier solution to move grips at runtime with python ? If not I will revert to trying to adapt @dale solution, but I’s been a few hours I struggled with this already…

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5894