Forgot password?

Create an account!

Forum

« back

Python – move objects using pythonscript

Messages

Please log in to write a message.

  • 2. pulgarata (Jan 30, 2014 15.41):

    Hi hossam,
    The GUID and the Object Name are differents properties. You can write and change the Object Name in the properties window, but you need the GUID to call the MoveObject function. This script work to me.

    def myFunction():
        name="nombre" #this must be the object name, in the properties windows.
        lista = rs.ObjectsByName(name)
        GUID_Objetc=lista[0]
        Start = rs.MeshVolumeCentroid(GUID_Objetc)
        End = (0,0,0)
        translation=rs.VectorSubtract(End,Start)
        rs.MoveObject(GUID_Objetc,translation)

    myFunction()

    Saludos!

  • 1. hossam (Jan 30, 2014 13.52):

    I want to move a mesh cube from its volume-centroid to the point 0,0,0 .. but I need it to be done fully automated by the python script without picking any thing from the screen ..

    I am a beginner .. so please help me as long as you can .

    - I tried this code , but turns Error :-
    import rhinoscriptsyntax as rs


    def myFunction(object,translation):
    rs.MoveObject(object,translation)

    hossam = rs.ObjectName(32)

    start = rs.MeshVolumeCentroid(hossam)
    End = rs.GetObject(0,0,0)
    translation = end-start


    myFunction(hossam,translation)

    thanks in advance !

Recommend

Why are these buttons gray?