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