Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

How to remove only children of Null object

Author
Message
  Topic Search Topic Search
mfersaoui View Drop Down
Member
Member
Avatar

Joined: 2015 Oct 06
Location: France
Online Status: Offline
Posts: 59
Direct Link To This Post Topic: How to remove only children of Null object
    Posted: 2015 Oct 06 at 3:16pm
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


Edited by mfersaoui - 2015 Oct 06 at 3:58pm
Back to Top
morbo View Drop Down
Member
Member


Joined: 2015 Oct 06
Online Status: Offline
Posts: 4
Direct Link To This Post Posted: 2015 Oct 06 at 7:57pm
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.



Back to Top
mfersaoui View Drop Down
Member
Member
Avatar

Joined: 2015 Oct 06
Location: France
Online Status: Offline
Posts: 59
Direct Link To This Post Posted: 2015 Oct 06 at 8:38pm
Originally posted by morbo

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.

Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.078 seconds.