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 !
Thanks Sebastian for your answer !
Unfortunately using CAWeightMgr as static class makes no difference for me: it's still not working.
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):
This should zero the weights of the selected joint - but it doesn't. Return value is always false
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);
... would be in python:
wmgr = c4d.modules.character.CAWeightMgr
wasSuccessfull = wmgr.AutoWeight(doc,False)
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.
... 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.
Ah ok, good to know, thanks for clarifying this - I've tested this in R19 ... but I forgot to mention that, sorry.
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
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 ?
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)
this is what I would like to achieve:
This is what works so far:
Removing all userdata from object 'a':
for id, bc in aObj.GetUserDataContainer():
Copy userdata from object 'b' to 'a'
for id, bc in bObj.GetUserDataContainer():
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:
TypeError: __setitem__ expected float, not c4d.Vector
Really strange. Do I miss any additonal (update-) commands besides "RemoveUserData" in order to really remove any userdata and set new userdata types ?
@m_adam said in Slow Python in R20 ?:
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.
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 ?
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.