I've been looking all over for Python documentation for STEP file imports for a few days, and haven't come across any solid info yet. Has anyone else found where this information might be found? Thanks!
Edit: I'm trying to import STEP files with specific settings as to not create a prompt window that usually happens when importing STEP files.
here's an example for the OBJ Import: https://github.com/PluginCafe/cinema4d_py_sdk/blob/master/scripts/FileImportExport/import_OBJ.py
You may want to adapt the code for STEP import.
Hi @Telerak, first of all, welcome in the plugincafe community.
Just a little request for your next topics, please mark your topic as a question see , I've done it this time, no worry at all.
You can find an example of the step file import bellow.
Copyright: MAXON Computer GmbH
Author: Maxime Adam
- Import STP/STEP with custom settings.
- Win / Mac
# Retrieves a path to load the imported file
selectedFile = c4d.storage.LoadDialog(title="Load File for STEP Import", type=c4d.FILESELECTTYPE_ANYTHING, force_suffix="step")
if not selectedFile:
# Retrieves STEP import plugin
plug = c4d.plugins.FindPlugin(c4d.FORMAT_STEPIMPORT, c4d.PLUGINTYPE_SCENELOADER)
if plug is None:
raise RuntimeError("Failed to retrieves the STEP importer.")
data = dict()
# Sends MSG_RETRIEVEPRIVATEDATA to OBJ import plugin
if not plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, data):
raise RuntimeError("Failed to retrieves private data.")
# BaseList2D object stored in "imexporter" key hold the settings
stepImport = data.get("imexporter", None)
if stepImport is None:
raise RuntimeError("Failed to retrieves BaseContainer private data.")
# Defines the settings
stepImport[c4d.CADIMPORT_SPLINES] = False
stepImport[c4d.CADIMPORT_ORIGINAL_UNITS] = False
# Sets the data by Scaling 10x and set to mm units
scale = c4d.UnitScaleData()
stepImport[c4d.CADIMPORT_SCALE] = scale
# Finally imports without dialogs
if not c4d.documents.MergeDocument(doc, selectedFile, c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS, None):
raise RuntimeError("Failed to load the document.")
if __name__ == '__main__':
Finally, you can find symbols for importer/exporter in FORMAT EXPORT page. Unfortunately, for options you have to search the C++ documentation, here the ones for STEP file Fstepimport.h as you can see it is not that much here, but if you take a look at the res files (Cinema 4D R20\resource\modules\cadexchange\description\Fstepimport.res) it also include Fcadimport resource so, that means you can also define the value from Fcadimport.h
I know the documentation get room to be improved on this topic. I will see what's possible to do.
Just want to add: You can also drag the import settings parameters from the preferences dialog to the python console, so the symbol names show up there.
Edit @m_adam: For more information see Python Console - Drag and Drop.
@mp5gosu @m_adam I'll test out these options and see how it works out. Thanks for the information guys, I appreciate it!