When providing support for new file format, is it required that you do that with C++ or you also can do it with .net?
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_PlugIns_FileExportPlugIn.htm
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_PlugIns_FileImportPlugIn.htm
Could you explan these classes as there’s no description and the rest is meaningless for me. Before putting something in the Python editor
Disclaimer: I don’t know if this works for Python, untested code, directly typed into discourse reply area, but…
For FileExportPlugIn
the process is roughly:
- derive class from
FileExportPlugIn
- override
protected FileTypeList AddFileTypes(FileWriteOptions fwo)
. This pretty much means instantiating aFileTypeList
, then adding an entry for each extension you want, something like
def AddFileTypes(self, fwo):
ftl = FileTypeList()
ftl.AddFileType("MY TYPE (*.mytyp)", "mytyp")
return ftl
- override
protected WriteFileResult WriteFile(string name, int index, RhinoDoc doc, FileWriteOptions fwo)
def WriteFile(self, name, idx, doc, fwo):
# idx is the index of extensions in order as added in AddFileTypes
# open a file with `name`
# iterate over the doc data and
# convert into the data format you want
# then write to that file. Finally return the proper
# FileWriteResult member
return FileWriteResult.Success
edit: it would be interesting to hear if this works with a Python plug-in. You’ll have to ensure you can compile a proper assembly with all assembly attributes and all. Essentially create a plug-in as you normally would, but with FileExportPlugIn
as the base class instead of PlugIn
Thank you Nathan.
This is a great description. I’ll try to do something.
Yes, I would really like at first to create a simple “Hello World!” plugin to get all attributes in place and test if it works with ironpython compiled dll.
My attempts so far have failed.