Remove Dynamics Body Tags Error

On 10/10/2015 at 20:19, xxxxxxxx wrote:

HI,
I was looking for a solution to remove Dynamic Body Tags with python, I tried with this script (below) it work perfectly with all other tags, except the dynamic body tags.
It gave me this Error message:

BugReport.txt

Script:

import c4d

def main() :
  Parent = doc.SearchObject("Parent")
 
  objList = Parent.GetChildren()
  selected = doc.GetActiveObjects(0)
 
  for ob in selected:
      obSelected = ob.GetName()
     
  if obSelected == "Parent" :
      for child in objList:
          TagList = child.GetTags()
     
          for childTags in TagList:
              childTags.Remove()

On 12/10/2015 at 04:14, xxxxxxxx wrote:

Hi,

at first a small reminder: Please, do not cross-post on several forums. It increases the chance of several users working redundantly on your posts.

The main problem you have with your script is, that you use it in a Python tag. You shouldn't modify the scene within a Python tag. In a Python tag your code will be executed every time, when the scene gets evaluated. It's basically the same answer (and problem) as you received in this thread on CGTalk.

Instead you should use a script (Script Manager from the Script menu) or a CommandData plugin.

Another thing with the code you posted is, that you would delete all tags from the objects and not only Dynamics tags. You would want to use GetType() or CheckType() for this. Another way would be the use of KillTag(), there you can directly specify the type of the tag to be deleted.

And finally I'm not sure, your code will actually reliably work with several active objects. I think, only the name of the last active object will be stored in obSelected.

On 12/10/2015 at 12:59, xxxxxxxx wrote:

Sorry for the cross-post on several forums, concerning the use of a Python tag. I've found this solution:

as I'm too forward on this project, I want to use only Python tag. and now I'm stuck on this problem, I followed your previous advice but I still have not found the solution to remove a dynamic body tag with python. Thanks so much for your help, I continued to searching the solution.

I have tested this solution but he dont work, it gave me the same Error message

Code:

 import c4d

def main() :
    Parent = doc.SearchObject("Parent")
    
    DTag = Parent.GetDown().GetFirstTag()
    
    if DTag.GetType() == 180000102 :
        DTag.Remove()

On 12/10/2015 at 14:59, xxxxxxxx wrote:

Finally, I've found the solution:

Code:

     import c4d

def main() :
    Parent = doc.SearchObject("Parent")
    
    objList = Parent.GetChildren()
    
    for child in objList:
        DTag = child.GetFirstTag()
        if DTag.GetType() == 180000102:
            DTag.Remove()
        
    c4d.CallCommand(12147)
        
if \__name\_\_=='\__main\_\_':
    main()