Skip to content

Instantly share code, notes, and snippets.

@NiklasRosenstein
Created September 15, 2013 13:13
Show Gist options
  • Save NiklasRosenstein/6570651 to your computer and use it in GitHub Desktop.
Save NiklasRosenstein/6570651 to your computer and use it in GitHub Desktop.
#c4dpytask #beginner How can you position the selected objects at the world origin?
# @rosensteinn #c4dpytask
#
# How can you position the selected objects at the world origin?
import c4d
def main():
# Retrieve a list of all selected objects in the scene
# and iterate over them.
objects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)
for obj in objects:
# Retrieve the global matrix of the object and set its
# offset vector to (0, 0, 0)
mg = obj.GetMg()
mg.off = c4d.Vector(0)
# Tell the document we are about to change the object. This
# enables to make the whole modification undoable to the user.
doc.AddUndo(c4d.UNDOTYPE_CHANGE, obj)
# Reposition the object.
obj.SetMg(mg)
# Tell Cinema to update its UI (so that the change is reflected
# immediately after the script is run)
c4d.EventAdd()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment