Moving Object by Node in Code from Rhino Python

Hallo Everyone, i am new in Programming by using python, and i am trying to figure out how to move an object by converting the Grasshopper Node into python code, it seems that the Code is working according to the Output,but its not changing anything in Rhino screen, is there any clue what could be missing ?
Thanks

Hi @Bibo,

Moving an object is a translation transformation. No node-in-code required.

import Rhino
import scriptcontext as sc

def test_move():
    filter = Rhino.DocObjects.ObjectType.AnyObject
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select objec to move", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success:
        return
    
    # Move 10 units in the world x-axis direciton
    dir = Rhino.Geometry.Vector3d(10.0, 0.0, 0.0)
    xform = Rhino.Geometry.Transform.Translation(dir)
    
    sc.doc.Objects.Transform(objref, xform, True)
    sc.doc.Views.Redraw()
    
if __name__=="__main__":
    test_move()

– Dale

Hallo @dale, Thank you for your answer, you are totally right, i also made this code without node in code and it worked

import rhinoscriptsyntax as rs
import scriptcontext as sc
Geo = rs.GetObjects(“select Object”,0)
move= rs.MoveObjects(Geo,[10,10,10])

i am just trying also to understand why it work by this method what was missing, because i am trying to use a further Grasshopper Component such as ( intersection Brep/line, Area and so on ). i would be thankful for any hint.

All this functionality is available via RhinoCommon, which Grasshopper uses.

– Dale