In my C# plugin I’d like to load objects defined in external files and place them to a specific location in my open document.
Also, I’d like to do it the other way round: export specific blocks into separate files.
Attempt 1: File3dm class
So far, I tried to use the File3dm class but it has no method to write an InstanceDefinition or InstanceObject into a file, nor does it give access to the block definitions in order to transform instances of them to specific points.
Attempt 2: InstanceDefinition/InstanceObject class
I also did not find a method to export/save and InstanceDefinition or InstanceObject.
Attempt 3: _-Import script
Always returns false:
RhinoApp.RunScript("_-Import myfile.3dm", true)
same with the commands _Load or _Open.
Could someone direct me to the right resource? I know my problem should be solvable.
The easiest way to import geometry from another file is to just script the Import command using RhinoApp.RunScript. However, in order to run a Rhino command from a plug-in command, your plug-in command must have a special attribute. See the following dev note for details.
Fantastic, @dale!
One suggestion: maybe the RunScript could raise a well-named exception indicating the problem instead of just returning false. Maybe you could also link to the resource about ScriptRunner command style attribute inside of the method’s documentation.
only works in the Rhino editor, when the user selects the block rather than specifying <blockname> programmatically. It does not run via RhinoApp.RunScript()
Thank you for the reminder. Yet, my filenames do not contain whitespace. Neither _BlockManager _Export <blockname> /my/absolute/path.3dm nor _ExplodeBlock <blockname> work already, also in Rhino’s command input box. The error message is “Unknown command: < blockname>”.
It seems that the macros do not accept a block name as argument.
Similar problem. In Rhino _Insert Haz also invokes the block manager dialog.
Via RhinoApp.RunScript(_-Insert Haz) however, it works to insert it but I am prompted in the UI for all the different options (insert as block, insertion point, rotation, scale factor).
How can I specify the options via RunScript?