I am experiencing trouble exporting nested blocks to e.g. step-files.
From further forum-discussions I got help from @stevebaer explaining the way to use a RhinoDoc and itt works perfecly fine. I am aware that if I had nested blocks I first need to establish a block tree and copy the definitions to the new headless doc first.
So that’s why I tried to script the blockmanager command in a C#-app. _-BlockManager E "BlockAssembly" "C:\Users\tstoltmann\Desktop\Export\BlockAssembly.stp" _Enter _Enter
Somehwere (don’t ask me where, but I still think I am able to remember this) I read that it (as well as scripting the Export-Command has issues with blocks.
But when I just paste this string above into the command line it works just fine!
Thanks!
On my pc it does not work.
May the problem be that I format the string like this: string script = $"_-BlockManager E \"{blockname}\" \"{filename}\" _Enter _Enter";
Okay, of course I did not include this: [Rhino.Commands.CommandStyle(Rhino.Commands.Style.ScriptRunner)]
I use the script in a class that is not in my RhinoCommand.
The method is called within the class.
So would this then still be used in the command or in the class I call?
namespace sampleBlockExport
{
[Rhino.Commands.CommandStyle(Rhino.Commands.Style.ScriptRunner)]
public class sampleBlockExportCommand : Command
{
public sampleBlockExportCommand()
{
// Rhino only creates one instance of each command class defined in a
// plug-in, so it is safe to store a refence in a static property.
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static sampleBlockExportCommand Instance { get; private set; }
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName => "sampleBlockExportCommand";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// TODO: start here modifying the behaviour of your command.
string filename = "C:\\Users\\username\\Desktop\\Export\\BlockAssembly.stp";
string blockname = "BlockAssembly";
// ---
string cmd = $"_-BlockManager E \"{blockname}\" \"{filename}\" _Enter _Enter";
Rhino.RhinoApp.RunScript(cmd, true);
// ---
return Result.Success;
}
}
}
Hi Gijs,
thanks a lot!
In my case the part doing the export is in a different class and not written in the command itself.
But, adding the top line you mentioned helped, it works perfect!