need help: cloth tag
-
On 19/10/2014 at 02:18, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 16
Platform: Windows ;
Language(s) : C.O.F.F.E.E ; XPRESSO ; PYTHON ;---------
hi everyone..
i need help
i want to do calculate cache in my multiple cloth tags in one user data button...
please anyone can help...
thanks(sorry for the my poor english)_<_mytubeelement_>_<mytubeelement =""loadBundle":true" ="relayPrefs" id="myTubeRelayElementToTa_<_mytubeelement_>_nt>
-
On 19/10/2014 at 09:43, xxxxxxxx wrote:
Hi Suda,
thanks for stopping by and don't worry, nobody will be blamed for his English. I'm no native speaker myself.
If I understand correctly, you want to automate the job of caching cloth tags. By intuition I'd try that with a Python script.
Unfortunately the SDK Support Team can't help with developing such scripts from scratch. But I'm quite sure, there's somebody in the community, who may want to try himself on this. Anybody? -
On 19/10/2014 at 11:42, xxxxxxxx wrote:
Hi Suda,
with Python you can do something like this:
import c4d def GetNextObject(op) : if op==None: return None if op.GetDown() : return op.GetDown() while not op.GetNext() and op.GetUp() : op = op.GetUp() return op.GetNext() def IterateHierarchy(op) : ClothTagList=[] if op is None: return count = 0 while op: count += 1 if op.GetTag(100004020)!= None: #id for the cloth tag ClothTagList.append(op.GetTag(100004020)) op = GetNextObject(op) return ClothTagList def main() : doc = c4d.documents.GetActiveDocument() first = doc.GetFirstObject() ClothTagList=IterateHierarchy(first) for i in ClothTagList: c4d.CallButton(i, c4d.CLOTH_DO_CALCULATE ) if __name__=='__main__': main()
-
On 20/10/2014 at 00:00, xxxxxxxx wrote:
Another idea would be to directly simulate the Cache button.
You can use c4d.CallButton(...) to do this. As parameters you'll need to pass the object and the button ID.
Be aware: This call needs to be done from the main thread. For a normal Python script this is no problem, in a Python Plugin you might need to care. -
On 20/10/2014 at 00:25, xxxxxxxx wrote:
Hi Andreas,
I´ve already used the call button in the script.
But thank you for the good hint to check the main thread inside a plugin.
As I´m scripting the snippet yesterday between changing diapers and singing a lullaby.
Here a more efficient script without a list and more error checking.@ Suda
Hope this helps.import c4d from c4d import gui def GetNextObject(op) : if op==None: return None if op.GetDown() : return op.GetDown() while not op.GetNext() and op.GetUp() : op = op.GetUp() return op.GetNext() def IterateHierarchy(op) : if op is None: return count = 0 while op: count += 1 if op.GetType!=c4d.Opolygon: dialog=gui.MessageDialog("A Polygon object for caching is needed",c4d.GEMB_OK) if dialog== 1: return if op.GetTag(100004020)!= None: ClothTag = op.GetTag(100004020) c4d.CallButton(ClothTag, c4d.CLOTH_DO_CALCULATE ) op = GetNextObject(op) return def main() : doc = c4d.documents.GetActiveDocument() first = doc.GetFirstObject() if first == None:return IterateHierarchy(first) if __name__=='__main__': main()
Best wishes
Martin -
On 20/10/2014 at 00:31, xxxxxxxx wrote:
Sorry, monkeytack, I didn't look closely enough. I didn't want to derogate your effort or idea.
Thanks for helping Suda out.
Would you allow us to integrate your code into our Python SDK docs? -
On 20/10/2014 at 02:36, xxxxxxxx wrote:
Hi Andreas,
no need to apologise, every thing is alright.
And Yes, feel free to integrate everything I´ve posted, if it fits and someone can take advantage of it.
It´s a pleasure.
Best wishes
Martin