Navigation

    • Register
    • Login
    • Search
    1. Home
    2. ruckzuck
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by ruckzuck

    RE: problems with CAWeightMgr

    Hi Manuel,

    perfect - in the Script Manager everything works as expected.
    Running the code via python tag isn't important to me - I just wasn't aware of this difference ScriptMgr <> PythonTag concerning the execution of the code.

    Thanks a lot for your solution !

    Cheers,
    Jens

    posted in Cinema 4D SDK •
    RE: problems with CAWeightMgr

    Thanks Sebastian for your answer !

    Unfortunately using CAWeightMgr as static class makes no difference for me: it's still not working.

    Simple example:

    • create plane
    • give plane a weight tag
    • create joint
    • insert joint into joint list of weight tag
    • open weight manager
    • select joint and click on "apply all" (mode should be already on "absolute")

    Now this single joint has 100% weighting of all plane points

    Give plane a python script tag and insert this single code line (while joint is still selected in weight manager):

    print c4d.modules.character.CAWeightMgr.ClearWeights(doc)
    

    This should zero the weights of the selected joint - but it doesn't. Return value is always false ☹

    posted in Cinema 4D SDK •
    problems with CAWeightMgr

    Hi,

    I'm struggling with c4d.modules.character.CAWeightMgr for quite some time now. Unfortunately I couldn't find any example how to access the weight manager using python.

    I tried to adapt the mini example in the C++ docs (https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_manual_caweigthmgr.html) but even this didn't work:

    CAWeightMgr::SetParameter(doc, ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE, ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE_VISIBLE);
    CAWeightMgr::SetParameter(doc, ID_CA_WEIGHT_MGR_AUTOWEIGHT_VISIBILITY_RATIO, 1.0); 
    CAWeightMgr::AutoWeight(doc, false);
    

    ... would be in python:

    wmgr = c4d.modules.character.CAWeightMgr
    wmgr.SetParameter(doc,c4d.ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE,c4d.ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE_VISIBLE)
    wmgr.SetParameter(doc,c4d.ID_CA_WEIGHT_MGR_AUTOWEIGHT_VISIBILITY_RATIO,1.0)
    c4d.EventAdd()
    wasSuccessfull = wmgr.AutoWeight(doc,False)
    print wasSuccessfull
    

    Parameter were set correctly (and UI was also updated properly) but the actual FunctionCall "AutoWeight" failed. And this goes on with almost all other functions 😞

    The only functions that work (at least for me) were selecting und unselecting joints in the weight manager.

    CAWeightMgr.NormalizeWeights()
    CAWeightMgr.ClearWeights()
    CAWeightMgr.AutoWeight()
    CAWeightMgr.MirrorWeights()
    CAWeightMgr.BakeWeights()
    CAWeightMgr.CopyWeights()
    CAWeightMgr.PasteWeights()
    CAWeightMgr.FlipWeights()
    CAWeightMgr.SmoothWeights()
    CAWeightMgr.ApplyWeightFunction()
    

    ... return code of the above functions is always False 😞

    Would be great when a detailed example of using one of these functions could be posted.

    cheers,
    Jens

    posted in Cinema 4D SDK •
    RE: How to copy (and remove) userdata via python ?

    Ah ok, good to know, thanks for clarifying this - I've tested this in R19 ... but I forgot to mention that, sorry.

    posted in Cinema 4D SDK •
    RE: How to copy (and remove) userdata via python ?

    Hi @m_adam, I also wish you a happy new year!

    Thanks a lot for your workaround - this is working perfectly ☺ 👍

    Just one little correction: I guess, it's c4d.DESCFLAGS_SET_0 instead of c4d.DESCFLAGS_SET_NONE

    Cheers,
    Jens

    posted in Cinema 4D SDK •
    RE: How to copy (and remove) userdata via python ?

    I guess there is a misunderstanding: I'm not only copying the userdata values but the complete structure between the objects. And I'm doing this after I've removed ALL userdata (not only the values) from the target object before ... so there should be no reason for any mismatching types. When I'm doing the removing part manually it's working - so the question is: why is using the python command "RemoveUserData" not the same like just deleting all userdata manually via the GUI ?

    1. A is a simple null object without any userdata at all
    2. copy userdata float structure (ID=1) from B to A
      (now A has a userdata tab and a userdata float element)
    3. set float element on A (let's say to float value 10.0) ... is working
    4. removing ALL userdata elements on A (using "RemoveUserData")
      (now A should be empty like in step 1). If I check in the GUI there is no userdata anymore, the userdata tab is gone ... but my guess is that the previously existing float element is still cached internally)
    5. copy userdata vector structure (ID=1) from C to A
      (this is working and when I check in the GUI there is now a vector element in A's userdata ... BUT internally this element seems to be still a float and not a vector like the GUI is indicating)
    6. trying to set this userdata element to any vector value ... FAILED - caused by type mismatch (??)

    Again: the crucial step seems to be step 4). Removing all userdata structure manually via GUI results in no errors. But the python way via "RemoveUserData" caused the error in step 6) 😞

    posted in Cinema 4D SDK •
    How to copy (and remove) userdata via python ?

    Hi,

    this is what I would like to achieve:

    1. copy userdata (only one vector element) from object 'b' to object 'a'
    2. remove all userdata elements from object 'a'
    3. copy userdata (only one float element) from object 'c' to object 'a'

    This is what works so far:

    Removing all userdata from object 'a':

    for id, bc in aObj.GetUserDataContainer():
       aObj.RemoveUserData(id)
    

    Copy userdata from object 'b' to 'a'

    for id, bc in bObj.GetUserDataContainer():
       aObj.SetUserDataContainer(id,bc)
    

    But here comes the problem: after I copied one userdata element (type: vector) from object 'b' to object 'a', I can't then just remove all userdata from object 'a' and then copy another userdata element (type: float) from object 'c' to (the apparently not entirely cleaned) object 'a'. It seems to me that even after the remove function the previous userdata type is still cached. As a result to this, I get this error when I try to enter any vector data to this userdata element:

    TypeError: __setitem__ expected c4d.Vector, not float
    

    When I remove all userdata manually from object 'a' using the GUI it works, but using code like "RemoveUserData" seems to be not the same. In other words: how can I replace a userdata element from type A by another element from type B using python ?

    I attached a file for testing:

    3 null objects:
    object 'b' has float userdata element
    object 'c' has vector userdata element
    object 'a' is the target object

    Select the python script tag and select the userdata tab. You can run these 3 functions:

    • remove all
    • b to a (float)
    • c to a (vector)
    1. run function "b to a (float)"
      -> float userdata element will be copied to object 'a'
    2. run function "remove all"
      -> userdata of object 'a' is gone
    3. run function "c to a (vector)"
      -> vector userdata structure is created on object 'a' but vector data can't be set:
    TypeError: __setitem__ expected float, not c4d.Vector
    
    1. check the userdata of object 'a': the gui shows the vector element but the "c to a" function can't set any vector data (?)
    2. remove the userdata of object 'a' manually and run function "c to a" again ... this time it works

    Really strange. Do I miss any additonal (update-) commands besides "RemoveUserData" in order to really remove any userdata and set new userdata types ?

    cheers,
    Jens

    0_1546388979560_userdata.c4d

    posted in Cinema 4D SDK •
    RE: Slow Python in R20 ?

    @m_adam said in Slow Python in R20 ?:

    Maxime

    Hi Maxime,

    thanks for trying to reproduce this behaviour.
    It's strange that you can see this speed difference only the first time. I can constantly see the low fps in R20 😞
    Today I also checked the speed in R18: here it's the same speed as in R19.

    It's interesting that reading values from thinking particles via python seems to have no significant impact to the speed (at least it's the same effect as in earlier versions) - but when I try to set any values (like "SetVelocity"), the speed drops drastically in R20.

    cheers,
    Jens

    posted in Cinema 4D SDK •
    Slow Python in R20 ?

    Hi,

    working with thinking particles controlled via python seems to be much slower in R20 as in earlier versions. I have a simple test file attached: in the xpresso tag 10000 particles are generated and in the python tag the velocity of each particle is read and set again (makes not much sense ... just for testing purpose).

    In R19 I get about 100 fps in the viewport after all 10000 particles are generated.
    In R20 I get only about 20 fps 😞

    Especially the SetVelocity command makes the difference: in R19 the fps is nearly the same (100 fps) with or without the SetVelocity command. In R20 I get the 100 fps without SetVelocity and it drops to 20 fps with SetVelocity. (??)

    Are there any R20 settings that I missed in order to get the same speed as in R19 ?

    Cheers,
    Jens

    0_1545350951878_python_test.c4d

    posted in Cinema 4D SDK •
    RE: getting 3D noise values

    Thanks @eziopan and Sebastian for your answers !

    So far I searched a way for getting values out of the 3D noise shaders. Starting point was the c4d.BaseShader class but it seems to me that accessing these shaders in order to get noise values is much more cumbersome than using the C4DNoise class and specifying the corresponding noise type as parameter 't' - as @eziopan has pointed out.

    So: thank you - problem solved ☺

    ... and sorry, I haven't read the Q&A system thoroughly enough - next time I will mark my post properly.

    cheers, Jens

    posted in Cinema 4D SDK •
    getting 3D noise values

    Hi,

    is there any way to get the color value of any x/y/z coordinate in a 3D noise space using python ?

    Like:
    input = vector(x,y,z)
    result = color value

    Cheers

    posted in Cinema 4D SDK •