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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    delete layer

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 436 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 07/04/2017 at 09:56, xxxxxxxx wrote:

      I was curious about the proper way to delete a layer with python. I know you can get the layer and do layer.Remove() which does delete the layer but it leaves the scene in a weird state sometimes. If I have objects solo'd when I use layer.Remove() it leaves all objects solo'd even though the layer is gone.

      Is there a proper way to go about this?

      Thanks

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

        On 10/04/2017 at 08:48, xxxxxxxx wrote:

        Hi,

        there's a small note in the Layer Manual in C++ docs that tells the trick.
        You basically need to clear the NBIT_SOLO_LAYER on the document, when removing a layer that has solo switched on.
        Like so:

        import c4d
          
        def main() :
            l = op.GetLayerObject(doc)
            if l is None:
                return
            l.Remove()
            doc.ChangeNBit(c4d.NBIT_SOLO_LAYER, c4d.NBITCONTROL_CLEAR)
            c4d.EventAdd()
         
        if __name__=='__main__':
            main()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 10/04/2017 at 12:01, xxxxxxxx wrote:

          That did it, thanks Andreas!

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