Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Clear LinkBox field

    Cinema 4D SDK
    python r19 windows
    2
    3
    979
    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.
    • A
      AndreAnjos
      last edited by AndreAnjos

      Hi everyone,

      Very basic question here, but I'm trying to clear the a LinkBox field.
      Would you use GeDialog.Command()? If so what BaseContainer to use?

      def Command(self, id, bc):
         if id == TAKES_LINKBOX:
             if type(self.linkBox.GetLink(activeDocument)) != c4d.modules.takesystem.BaseTake:
                 test = c4d.BaseContainer()
                 self.Command(TAKES_LINKBOX, **???**)
      

      Thank you all in advance! 😀

      Andre

      1 Reply Last reply Reply Quote 0
      • a_blockA
        a_block
        last edited by a_block

        Hi Andre,

        you can simply use SetLink(), the opposite of GetLink().

        In order to clear a link box, you'd call: self.linkBox.SetLink(None)

        The type you do in your code snippet is a bit unconventional in terms of Cinema 4D's API (not wrong though), but usually we recommend to stay in our API for example with CheckType() or IsInstanceOf(). But in the end, I think, you don't even need the type check, if you simply restrict the types accepted by the link box.
        For example like so:

        bcAcceptedObjects = c4d.BaseContainer()
        bcAcceptedObjects.InsData(c4d.TakeBase, "") # only allow BaseTakes to be accepted
        bcLinkBox = c4d.BaseContainer()
        bcLinkBox.SetData(c4d.DESC_ACCEPT, bcAcceptedObjects)
        self.linkBox = self.AddCustomGui(2001, c4d.CUSTOMGUI_LINKBOX, "My Link", c4d.BFH_SCALEFIT | c4d.BFV_CENTER, 0, 0, bcLinkBox)
        

        I turned this thread into a question.

        Cheers,
        Andreas

        1 Reply Last reply Reply Quote 3
        • A
          AndreAnjos
          last edited by

          Hi Andreas,

          Thank you very much! ☺
          It works like a treat and I appreciate your thorough explanation!

          Happy Friday!

          Andre

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