order of operations

On 11/09/2016 at 23:28, xxxxxxxx wrote:

hello , 
when I want to disable an object , do something with it , then re-enable it with the same script , the result I get is the same if the first (disable ) wasn't there , so I have to make another script to complete the first script job . 
another example , is when I set the target of pose morph = obj  , then make the target = none (to clear the field , if it is not the correct way , please let me know ) in one code , the result is the same if I removed the part of the target = obj , so I have to make separate script , and every thing works fine .

what I want to know , is there an order of operations in the python code ? or it is just from top to bottom , I tried to arrange my code , so the part I want to compile first is in the beginning and the other part in the end , but this seems to not work , so is there is a workaround to this problem without having to do many scripts ?
if it is necessary I can provide the code I am working with , 

On 12/09/2016 at 08:21, xxxxxxxx wrote:


I have to admit, I'm not sure I understand your questions.
After reading it multiple times, it could be you are missing a EventAdd() somewhere, but really this is just a wild guess.
Maybe a bit of code could help clear things up. But please also provide us with the usual details: Where are you using Python (Script Manager, Python Generator, a plugin)? If a plugin, what type and in which function?

On 12/09/2016 at 10:12, xxxxxxxx wrote:

hi , thanks for reply .
I put EventAdd() in the end of the script ,
I use the script in the script manager .
this is a simple script , no scene files needed , just paste it in the script manager.

import c4d
def main() :
   #this is just scen preparation  
    obj = c4d.BaseObject(c4d.Ocube)
    morph =c4d.BaseObject(c4d.Osphere)
    c4d.CallCommand(12236) #make editable
    c4d.CallCommand(12236) #make editable
    pmTag =c4d.BaseTag(c4d.Tposemorph)
    mo = pmTag.AddMorph()
    #this is the problem 
    pmTag[c4d.ID_CA_POSE_TARGET]=None #problem line
if __name__=='__main__':

as you can see if you run the script you will see the cube will still have a cube shape , but if you 
comment the "problem line " , the cube will have a sphere shape, then with another script just make the target = None , the target will be empty , but the cube will still have the sphere shape in the morph , which is what I want .
this is not the only situation I have this problem , but it is just an example , is it possible to make it in one script without the need to split it into another script ?

On 12/09/2016 at 10:51, xxxxxxxx wrote:

The "make editable" command doesnt re-evaluate the object. Using
SendModelingCommand() would do this, or use DrawViews() or I
think ExecutePasses() works as well before the make editable command.

On 12/09/2016 at 10:56, xxxxxxxx wrote:

Originally posted by xxxxxxxx

The "make editable" command doesnt re-evaluate the object. Using
SendModelingCommand() would do this, or use DrawViews() or I
think ExecutePasses() works as well before the make editable command.

thanks for the tip , but I don't work with make editable command , it is just to create a simple scene to show the problem , because I didn't want to upload a scene file.:slightly_smiling_face:

On 13/09/2016 at 00:50, xxxxxxxx wrote:


the following two lines:

    pmTag[c4d.ID_CA_POSE_TARGET]=None #problem line

do basically nothing (as you already found out). The parameter is set to one value (morph) and directly afterwards to another value (None). Very simplified like writing one value into a BaseContainer and directly afterwards overwriting it with another value.

Instead you need to give Cinema 4D the chance (or rather command it to) evaluate the scene graph and execute all expressions (in this case the PoseMorph).
Like so:

    doc.ExecutePasses(None, False, True, False, c4d.BUILDFLAGS_0)
    pmTag[c4d.ID_CA_POSE_TARGET]=None #problem line

Note: The parameters passed to ExecutePasses() may vary depending on the given scenario.

On 13/09/2016 at 03:16, xxxxxxxx wrote:

thank you very much Andreas , 
this solved my problem , did not know there is such commands to tell c4d , evaluate the scene graph , I will have to read the documentation , thanks again for the help :)