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

    Delete object by name

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 701 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 05/07/2014 at 03:50, xxxxxxxx wrote:

      Hi, I am new to Python and am creating a rig. When the user clicks a userdata checkbox, I need a specific object deleted. Here is what I have that doesn't work.

      def delete() :

      # find "MAT and Surface Thumbs"
          mat_thumbs = doc.SearchObject('MAT and Surface Thumbs')
          if obj.mat_thumbs:
              obj.Remove('MAT and Surface Thumbs')

      Can anyone help? Thanks.

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

        On 05/07/2014 at 07:16, xxxxxxxx wrote:

        Hi,

        1. What is obj? But nevermind, you can be sure that mat_thumbs won't be assigned to its
          attributes if you don't do so explicitly
        2. Assuming that mat_thumbs was an attribute of obj, you'd still need to use it when
          calling Remove(), like obj.mat_thumbs.Remove()
        3. The Remove() method does not need an argument.
        def delete() :
            mat_thumbs = doc.SearchObject('MAT and Surface Thumbs')
            if mat_thumbs:
                mat_thumbs.Remove()
        

        -Niklas

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

          On 05/07/2014 at 07:44, xxxxxxxx wrote:

          Here is my entire code block but it does not seem to remove the object. (This is part of the rig I PM'd you about. I will probably end up paying you to do it, based on your response to my email but in the meantime, the more I can learn about getting this all to work, the better. Thank-you for your time and patience.)

          import c4d
          from c4d import gui

          def delete() :

          mat_thumbs = doc.SearchObject('MAT and Surface Thumbs')
            if mat_thumbs:
                mat_thumbs.Remove()

          if __name__=='__main__':
            main()

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

            On 07/07/2014 at 01:53, xxxxxxxx wrote:

            I guess you have to add c4d.EventAdd().
            So tel cinema 4d to update.

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