How to remove only children of Null object

On 06/10/2015 at 15:16, xxxxxxxx wrote:

HI,
I was looking for a solution to remove children of null object with python, I tried using GetChildren() and obj.Remove() and it gave me this:


c4d file: remove_children_object_python.c4d

On 06/10/2015 at 19:57, xxxxxxxx wrote:

import c4d
#Welcome to the world of Python

def main() :
 
  obj_parent=doc.SearchObject("Parent")
 
  childList=obj_parent.GetChildren()
 
  print(childList)
 
  for child in childList:
      child.Remove()

When you get a list of objects, you have to go through it and Remove() every single object.

On 06/10/2015 at 20:38, xxxxxxxx wrote:

Originally posted by xxxxxxxx

import c4d
#Welcome to the world of Python

def main() :
 
  obj_parent=doc.SearchObject("Parent")
 
  childList=obj_parent.GetChildren()
 
  print(childList)
 
  for child in childList:
      child.Remove()

When you get a list of objects, you have to go through it and Remove() every single object.

Oh Nice! :clap:

Thanks a lot for your time and for this useful information.