Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi,
With the help of this page, I am able to set priority data on a TAG, but not on the SKIN DEFORMER.
I get a NoneType error. Is there a separate code for setting priority data for the SKIN DEFORMER?
NoneType
Here is the code so far:
import c4d def SetPriority(Mode, Value, obj): pd=obj[c4d.EXPRESSION_PRIORITY] print pd # I get a NONE object here for skin deformer pd.SetPriorityValue(c4d.PRIORITYVALUE_MODE, Mode) pd.SetPriorityValue(c4d.PRIORITYVALUE_PRIORITY, Value) obj[c4d.EXPRESSION_PRIORITY]=pd return def main(): obj = doc.SearchObject("skin_deformer") SetPriority(4, 2, obj) # Execute main() if __name__=='__main__': main()
hi,
remember the brackets [] return a copy of the BaseContainer. You are updating a copy of the data. Either you need to reinject those data to the object or you can use GetDataInstance to retrieve an instance of the BaseContainer. But you still need to reinject your data into this BaseContainer.
[]
import c4d def SetPriority(obj, mode, value): if obj is None: return False bc = obj.GetDataInstance() if bc is None: return False pd = bc.GetData(c4d.ID_CA_SKIN_OBJECT_PRIORITY) if pd is None: print (obj) raise ValueError ("can't retrieve expression priority") pd.SetPriorityValue( c4d.PRIORITYVALUE_MODE, mode) pd.SetPriorityValue( c4d.PRIORITYVALUE_PRIORITY, int(value)) bc.SetData(c4d.ID_CA_SKIN_OBJECT_PRIORITY, pd) obj.Message(c4d.MSG_UPDATE) return def main(): obj = doc.SearchObject("skin_deformer") if obj is None: raise ValueError("object not found") SetPriority(obj, c4d.CYCLE_DYNAMICS,3) c4d.EventAdd() # Execute main() if __name__=='__main__': main()
Cheers, Manuel
@m_magalhaes Thanks for the clarification. The code works as expected.
Although I find it weird since the code I posted above (from the Cineversity) works for tags despite using the brackets []
brackets []
Not sure if this would make sense. I use the previous code with bracket and just changed obj[c4d.EXPRESSION_PRIORITY] to obj[c4d.ID_CA_SKIN_OBJECT_PRIORITY].
obj[c4d.EXPRESSION_PRIORITY]
obj[c4d.ID_CA_SKIN_OBJECT_PRIORITY]
And it now works as expected.
you initial code was correct, the only problem was that you used the wrong id. @m_magalhaes probably overlooked the fact that you did write the priority data back (obj[c4d.EXPRESSION_PRIORITY]=pd) and just went for the common mistake in such cases. His version with GetData and SetData is just a bit more verbose and doesn't leave you at the mercy of __getitem__ and __setitem__, i.e. the bracket syntax and also uses the correct id, which "makes it work".
obj[c4d.EXPRESSION_PRIORITY]=pd
GetData
SetData
__getitem__
__setitem__
Cheers, zipit
@zipit said in Unable to Set Priority Data for Skin Deformer:
probably overlooked
correct, friday evening