A problem about getting an object width value with python

I have an null container with a python tag. Object structure as below:
--Loft Object

  1. Python tag has a single user data that holds an object link value
  2. Loft object uses two instances: start and end.
  3. Their link values are assigned by python tag.
  4. and lastly I grab loft object's width value and use that value as cube object X location.

problem is when I assign new value to loftShapeLink user data I can't get loft object's width value correctly. I have to trigger python tag again and that time it runs perfectly. As you can see in sample file, after new shape assignments instance object link value is correctly assigned but width value is not updated(I got previous value).

How can I get correct width value after first execution of the script? This is a problem because I can't use takes to render scenes. Because when marked takes render is started scripts run only 1 time for active take and shape positions are not correctly rendered.

Note: I have to use null containers for shapes just because axis points. I tried only shape objects as link objects but it is not effect the result.
thank you

Hi @delizade,

thank your for reaching out to us. Assuming I do understand you correctly, you have to simply set the execution priority of the Python tag to Generator. I have attached a "fixed" version of your file. I hope this answers your question.



MAXON SDK Specialist

@zipit hi,
thank you for your help. I tested it but in this case it can't get currently assigned linked object. Old shape assignment is staying after new shape assignment. if you have time you can see this by assigning different shape objects.

I somehow doubt this is an issue that could be solved by changed priority.
The Python tag is executed once during the execution of the scene (lets leave exceptions to this rule aside for now). Regardless of priority or exact execution order, the tag's code gets executed once. With priority you can change the point of time of this one execution or change the order of the execution of all entities contained in a scene.
But in your Python tag you do modify the scene by changing the two links. And then you want to have the result of this change a few lines later. But nothing has changed so far. You have only changed a link parameter of two instances in the middle of C4D evaluating the scene entity by entity. In order for the Loft to change it's size, the Loft needs to be executed. But when you read the size, it's still the Python tag being executed... you get where I am heading?
I don't think, what you are trying to do here is possible with a single Python tag. Instead do it in two. Have one assigning the links. The other places the cube based on Loft size. Then you can use the priorities of the tags to make sure, the execution order is as follows:

  1. Tag "Set Links"
  2. Loft (actually this implies execution of the instances beforehand)
  3. Tag "Position Cube"


@a_block hi,
thank you for the suggestion. I really did not think that using 2 tags instead of one. This may be work and thank you so much for this I hope it works (probably will work I'm guessing)

@a_block I tried your suggestion and it is working.

First tag setting instance links. Tag priority: Generator and index: -1
Second tag is getting width value and sets cube position with it. priority: Generator index:0

I moved user data to null object instead of using it on python tag. (Some one have suggested this before for another issue but I don't understand why we should use user data on python tag instead of object)

By the way after @zipit reply I tried to research about priority but could not find them in 3d4 doc. if you know a good page I would want to know it.

thank you both again.

Hi @delizade,

Thanks @a_block for helping out! @delizade you can find the description for the priority options in the Python Tag section of the user manual.


MAXON SDK Specialist