Created
September 15, 2013 13:13
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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