mcneel / rhino.inside

Sample Projects for Rhino.Inside
MIT License
382 stars 169 forks source link

Launch Rhino using Rhino.Inside AutoCAD and output geometry #288

Closed ThomasMahon closed 1 year ago

ThomasMahon commented 1 year ago

@kike-garbo is it possible to launch Rhino and add geometry instantiated from RhinoCommon in an AutoCAD plugin?

sbaer commented 1 year ago

I believe that is what the acad sample in this repo does https://github.com/mcneel/rhino.inside/tree/master/Autodesk/AutoCAD

ThomasMahon commented 1 year ago

Hi @sbaer I've used that to test and while it works, it doesn't launch the Rhino application. I tried some hacks to force Rhino to open but it caused exceptions. I'm targeting AutoCAD 2024 whereas the example used a much older version so not sure if some framework issue is preventing it from launching?

sbaer commented 1 year ago

Rhino is launched, but it is launched without UI. If you want user interface, you should construct the RhinoCore instance with the WindowStyle.Normal parameter. https://github.com/mcneel/rhino.inside/blob/master/Autodesk/AutoCAD/Plugin.cs#L51

something like

var style = Rhino.Runtime.InProcess.WindowStyle.Normal;
m_rhino_core = new Rhino.Runtime.InProcess.RhinoCore(new[] { $"/scheme={SchemeName}" }, style);
ThomasMahon commented 1 year ago

Awesome, that works. Thanks