Describes how to reuse custom user interface created with the classic API in the Node Editor. User interfaces allow the user to define or change the value of attributes. Cinema 4D can display descriptions that use data types created with the Classic API while the node core deals with Maxon API data types. To use those data types and descriptions in the node editor, those data types must be converted from the type GeData to the type Data and vice-versa. That means the data types must exist in both the Maxon API and the Classic API. For both API to communicate, a conversion must be implemented. This is done by implementing an interface that inherits from UiConversionInterface with just a couple of functions. Those functions define what are the data types supported and how the conversion is done in both directions. An example can be found in the sdk.zip provided with Cinema 4D. This example shows how to use the "Dots Data" custom UI example in the node editor.
The function QuerySupportedDataTypes must be overridden to define what data types the implementation can handle. To do that, the BaseArray passed to this function must be filled with the data types that are supported. This array will also be used to define the list of UI that can be used to handle an attribute of this kind of data type.
While the Maxon API uses the type Data to store any kind of data types, the Classic API uses the type GeData. Nodes are functions that take data as inputs, process them and provide the result of this processing.
To create a user interface that can be used in the node editor:
The interface has two functions that must be overridden, ConvertToCore and ConvertToC4D. Both functions must be fully functional otherwise some data will be lost. For example, the data can be stored inside a BaseContainer in the Classic API while it is stored as a BaseArray in the Maxon API. In case of complex data, the data can be copied or reconstructed. Keep in mind, to increase speed, that data can be moved to avoid copying.
In the function ConvertToCore, data is converted from the type GeData to the type Data. In the function ConvertToC4D, data must be converted from the type Data to the type GeData.
To display the value of an attribute, a description must be created. This description will display Classic API gadgets inside the Node editor that use the Maxon API description system. Just like in the Classic API, some parameters must be defined using a BaseContainer, for example, the name of the gadget or the custom UI that will be used. In conjunction with that, the description system used by the Maxon API must be used to define the place where the gadget must be inserted in the UI. This is done inside the function CreateC4DDescription. The function has many parameters to retrieve the information about the description for both systems, DescID, InternID, DescTranslation.
Now that the conversion interface has been defined, the Resource Editor must be used to create the User Node that will be instantiated in the Node Editor.
Once the Resource Editor is opened inside Cinema 4D:
net.maxonexample.handbook.customgui.dotdata
.net.maxon.object.base
with the check-boxes Data, UI and String checked. Update the information of the node using the button < or > to move to another element and come back.Dot Data Example
.node
.