How To Change Object Axis According Null Position

Changing Axis of an Object according to null’s position with Python


This post has already been read 1952 times!

In this tutorial we will learn how to change axis of an object according to independent null object’s position

Now create a cube or something and make sure you convert it into an editable object by pressing c on your keyboard as a shortcut. On objects panel, right click on your cube and add xpresso tag from cinema 4d tags – xpresso.

We will add a python node. To do that find python node from x-pool and drag it into your xpresso editor.

Click on python node and delete all strings coming by default and replace it with the code below;

import c4d

def setAxis(obj, m):
“””Set obj axis to Matrix m.

inv = ~m * obj.GetMg()
for i, point in enumerate(obj.GetAllPoints()):
obj.SetPoint(i, point * inv)
obj.Message (c4d.MSG_UPDATE)

def main():
global Source
global Matrix
if Source.CheckType(c4d.Opolygon):
setAxis(Source, Matrix)


Now add your cube object and null object into xpresso editor. Create an Global Matrix in”Null” object node’s output box and connect it to Python Node‘s “Matrix” Input. Now select “Object” as an output port in cube object node, this should be connected to Python Node‘s “Source” input box.

And we’re done! If you simply change position of your Null Object then click your cube object you will see its axis is being changed  according to null object’s position. Useful…

You may download file:


Leave a Reply