mcneel / rhino.inside

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

Licence question Rhino Inside AutoCAD #290

Closed ThomasMahon closed 1 year ago

ThomasMahon commented 1 year ago

How are license's allocated using Rhino Inside AutoCAD? In the boilerplate provided in this repo I'm assuming licence allocation occurs when the Rhino core is initialized?

m_rhino_core = new RhinoCore(new[] { $"/scheme={schemeName}" }, style);

sbaer commented 1 year ago

I'm assuming licence allocation occurs when the Rhino core is initialized?

That is correct

ThomasMahon commented 1 year ago

@sbaer Thanks. I have two other related questions:

  1. Does calling Dispose on RhinoCore release the licence allocation?
  2. Why can't we initialize a new instance of RhinoCore after its disposed in the same AutoCAD session? We get a runtime exception, indicating perhaps that dispose only partially shuts down Rhino and there are other services or resources still in memory that haven't been removed so the new instance fails.
sbaer commented 1 year ago

Dispose is really only meant to be called during shutdown. Once Rhino is loaded into the process, a licence is allocated and cannot be deallocated until the process is shut down.

ThomasMahon commented 1 year ago

@sbaer thanks for the info.

I have one other issue - how can I set the units of the Rhino doc without launching the application?

For example, for debug builds we want to launch the Rhino app UI. This works fine when we set the units to mm.

However for release versions we do not want the UI app, we just need Rhino running in the background, which means the ActiveDoc is null so the following code throws an exception. Its really important we can set the units. How can we do this for release builds using headless rhino?

 var schemeName =
                $"Inside-{HostApplicationServices.Current.Product}-{HostApplicationServices.Current.releaseMarketVersion}";

#if DEBUG
            var style = WindowStyle.Normal;
            _rhinoCore ??= new RhinoCore(new[] { $"/scheme={schemeName}" }); //, style);
#endif

#if !(DEBUG)
            _rhinoCore ??= new RhinoCore(new[] { $"/scheme={schemeName}" });
#endif
            var rhinoDoc = RhinoDoc.ActiveDoc;
            rhinoDoc.ModelUnitSystem = this.GetRhinoUnitSystem(internalUnits);
sbaer commented 12 months ago

@ThomasMahon you should be able to create a headless doc and set it as the ActiveDoc.