0

Accessing and Changing Importers/Exporters Settings

Retrieving and modifying a scene loader/saver options is usually needed when developing a batch importer/exporter.

To get and set an exporter’s settings, you do not have to call GetWorldPluginData() and SetWorldPluginData() (a common pitfall for CINEMA 4D plugins developers), but a MSG_RETRIEVEPRIVATEDATA message has to be sent to the exporter instead. This is because the loader/saver plugins hold their data within their BasePlugin object.
Here is an example that shows how to setup an Alembic export in C++:

BaseList2D* exporter;
// Find Alembic exporter plugin (1028082 is its ID, find out below how to find it)
BasePlugin* plug = FindPlugin(1028082, PLUGINTYPE_SCENESAVER);
// If found, send MSG_RETRIEVEPRIVATEDATA to get the Alembic exporter private data
if (plug && plug->Message(MSG_RETRIEVEPRIVATEDATA, &exporter))
{
    if (!exporter) return FALSE;

    // Get the container data instance
    BaseContainer *data = exporter->GetDataInstance();
    if (!data) return FALSE;

    // Set Alembic export settings

    data->SetBool(ABCEXPORT_HAIR, TRUE);
    data->SetBool(ABCEXPORT_PARTICLE_GEOMETRY, TRUE);
    data->SetBool(ABCEXPORT_XREFS, TRUE);

    // Export the document
    SaveDocument(doc, "C:\\model.abc", 
          SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, 1028082);
}

How can you find the ID of any exporter?
Here is a simple Python script that prints to the console the name and ID of all the registered scene saver plugins:

import c4d
from c4d import plugins

def main():
    plugs = plugins.FilterPluginList(c4d.PLUGINTYPE_SCENESAVER, True)
    for plug in plugs:
        print plug.GetName(), '-', plug.GetID()

if __name__=='__main__':
main()

You can print all the registered scene loader plugins by just replacing c4d.PLUGINTYPE_SCENESAVER with c4d.PLUGINTYPE_SCENELOADER in this script.

Avatar

Yannick Puech

Former SDK Support Specialist SDK Support and Documentation. Yannick has experience developing tools and plugins in the video game, middleware and animation industries.

Leave a Reply

Your email address will not be published. Required fields are marked *