Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    How to remove only children of Null object

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 312 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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! 👏

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post