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;

[highlight1]

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)
obj.SetMg(m)

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

[/highlight1]

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:

[wpdm_package id=1229 template=”link-template-default.php”]

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.