Storing Custom BaseList2D Type in BaseDocument

On 23/12/2014 at 16:59, xxxxxxxx wrote:


How would I go about storing a custom type that inherits from c4d.BaseList2D inside of a c4d.documents.BaseDocument? Basically I want to create my own class of object similar to a LayerObject or RenderData and store it inside of a document.

Specifically, I'm trying to store a LayerComp class. I'm currently doing this by storing all of the data in a BaseContainer saved in the c4d.ID_BS_HOOK scene hook - but I don't get the benefit of animation, selection, or Undo support automatically.

I think I'm looking for something like document.InsertObject() - but for my own custom data type - and I don't see anything in the API for this specific case.


On 24/12/2014 at 00:45, xxxxxxxx wrote:


for such custom objects you can create a class directly based on NodeData. Custom data types are something completely different.

Best wishes,

On 24/12/2014 at 08:28, xxxxxxxx wrote:

Could you please tell us how to get the data from a NodeData plugin?

The docs tell us this much:

NODE_PLUGIN_ID = 1000006  
class MyNode(plugins.NodeData) :   
  def Init(self, node) :      
      ndData = node.GetDataInstance()  
      ndData.SetString(1000,"My String value")  
      ndData.SetLong(1001, 55)  
      return True  
  def Message(self, node, type, data) :  
      doc = c4d.GetActiveDocument()  
      bc = node.GetDataInstance()  
      return True  
  def Read(self, node, hf, level) :  
      return True  
  def Write(self, node, hf) :  
      return True  
if __name__ == "__main__":  
  plugins.RegisterNodePlugin(NODE_PLUGIN_ID, "My Node", 0, MyNode(),None, 0)

That's works for creating the plugin...But how do we get at it's data?
In the script manager. I've tried using this: myplugin = c4d.plugins.FindPlugin(1000006, c4d.PLUGINTYPE_ANY)
But I can't seem to get it to return the data values in the plugin that way.


Can we create an instance of it in memory?  Or does this Node need to be physically created in the document like a tag? Maybe that's why I'm not getting any values from it?
If it needs to be physically in the document. Then how do we do that? Do we attach it to a Tag plugin?
The deeper I dive into this. The more I realize how much information is missing from the docs.

On 24/12/2014 at 12:19, xxxxxxxx wrote:

Thanks for pointing me in the right direction in terms of which class to use. Now, after I've created my own NodeData object - how do I insert it into my document?

I want the data to be stored in the document, but I don't want it to show up in the OM, or the Materials Manager - I want to be able to read/write the objects into/from the document and display them in a custom dialog. I think I'm looking for the equivalent of doc.InsertObject() and doc.GetFirstObject() - but I want it for my custom LayerComp class.

On 24/12/2014 at 12:51, xxxxxxxx wrote:

^I have a C++ example of adding a custom Node plugin to the document using a SceneHook plugin.
Which sounds like what you're asking for.
But the problem is that Python has never supported the SceneHook plugins.

I haven't used R16 that much. Are SceneHook plugins supported now?
If not. Maybe we can add a custom Node using a hidden tag, or some other work around?


On 26/12/2014 at 11:21, xxxxxxxx wrote:

I'd like to avoid hidden objects/tags as they're still part of the scene hierarchy and subject to the influence of scene layers. Perhaps this is a problem that can only be solved via the C++ SDK. Thanks!