Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rhino Inside AutoCAD: Creating headless document causes inconsistent state and fatal error/crash #291

Open
ThomasMahon opened this issue Jul 24, 2023 · 0 comments

Comments

@ThomasMahon
Copy link

ThomasMahon commented Jul 24, 2023

We need to set the units of the Rhino inside document in our AutoCAD application. Using the following for debug builds works fine:

var style = WindowStyle.Normal;

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

var rhinoDoc = RhinoDoc.ActiveDoc;
rhinoDoc.ModelUnitSystem = this.GetRhinoUnitSystem(internalUnits);

However, for release builds we don't need the UI, so a headless version is required. However:

  1. It doesn't create a document,
  2. It's therefore not possible to set the units, and
  3. What document exactly are we using?
  4. If we create a headless document, the application becomes unstable and inadvertently crashes AutoCAD without warning. No breakpoints hit either, its fatal.
var style = WindowStyle.NoWindow;
_rhinoCore ??= new RhinoCore(new[] { $"/scheme={schemeName}" }), style);

var rhinoDoc = RhinoDoc.CreateHeadless("...a mm template file");
rhinoDoc.ModelUnitSystem = this.GetRhinoUnitSystem(internalUnits);

We've checked the validity of the RhinoDoc.ActiveDoc straight after creating the headless doc and its valid and its units are successfully set. var style = WindowStyle.Hidden has also been tested and it seems to be stable, however it always displays the splash screen which we don't want. Rhino.UI.Dialogs.KillSplash() doesn't seem to work.

What is the correct procedure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant