On 16/04/2018 at 23:28, xxxxxxxx wrote:
This is my problem:
I have an object ("cone") with an Ttargetexpression.
I transform the target object ("ziel") via a python script in a "for" loop (e.g. 10 steps)
ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Z] = float(i)*100
After each step i trasform a group including the "cone" and the "ziel" object to a new object ("c4d.CallCommand(12233, 12233)").
After running the script i got 10 new groups with 2 objects each. the "ziel" object has changed its position in each step) but the "cone" has not rotated.
I think it has to do with priority of the "Ttargetexpression" Tag. But i don't know how to handle the problem.
It would be great if someone could help me.
On 17/04/2018 at 05:19, xxxxxxxx wrote:
welcome to the Plugin Café forums
The problem is, scripts (and all CommandData plugins actually) run in the main thread (and thus block the main thread). So Cinema 4D is doing nothing else but executing your script. Or in other words, the scene does not get evaluated during your for-loop.
The solution is to trigger the evaluation of the scene by calling ExecutePasses() in your for-loop.
On 17/04/2018 at 05:29, xxxxxxxx wrote:
Thank you very much for your reply and the nice welcome.
Unfortunatly it does not yet work
This is my code:
from c4d import gui
#Welcome to the world of Python
def main() :
objekt_ziel = doc.SearchObject('ziel')
objekt_wuerfel = doc.SearchObject('wuerfel')
hauptobjekt = doc.SearchObject('ICL_python')
for i in xrange(-10, 10) :
objekt_ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X] = 0
objekt_ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Y] = 500
objekt_ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Z] = float(i)*100
doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
hauptobjekt.SetName("ICL_animation_" + str(i) )
c4d.CallCommand(12233, 12233) # Akt. Zustand in Objekt wandeln
Can you please help me?
On 17/04/2018 at 05:41, xxxxxxxx wrote:
can you please tell me in what way it does not work?
I tried your script here with the following object hierarchy:
And as a result of your script I get 20 Null objects "ICL_animation_N" with "wuerfel" as a child, each pointing into a different direction.
On 17/04/2018 at 06:33, xxxxxxxx wrote:
The scene looks like this:
The "kegel" object has an "Ausrichten"-Tag (sorry. I do not know the english name of that tag) with "ziel" as its target.
The result is 20 Null object with each one translated "ziel" and one not rotated "kegel".
So i think the "Ausrichten"-Tag does not work within my script.
Thanks for the help.
On 17/04/2018 at 06:42, xxxxxxxx wrote:
But your script searches for "wuerfel"...
On 17/04/2018 at 06:43, xxxxxxxx wrote:
Sorry. it was an old version of the script.
Please forget this line.
On 18/04/2018 at 10:03, xxxxxxxx wrote:
Now, I'm confused about which line to forget.
I still think, here the script works as expected. See here the result of your script: