diff --git a/ConnectorGrasshopper/ConnectorGrasshopperShared/Extras/Utilities.cs b/ConnectorGrasshopper/ConnectorGrasshopperShared/Extras/Utilities.cs
index 101ca74e88..022dcfb1c8 100644
--- a/ConnectorGrasshopper/ConnectorGrasshopperShared/Extras/Utilities.cs
+++ b/ConnectorGrasshopper/ConnectorGrasshopperShared/Extras/Utilities.cs
@@ -10,7 +10,6 @@
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
using Microsoft.CSharp.RuntimeBinder;
-using Rhino;
using Rhino.Display;
using Rhino.Geometry;
using Speckle.Core.Kits;
@@ -27,17 +26,9 @@ public static class Utilities
/// Gets the appropriate Grasshopper App name depending on the Version of Rhino currently running.
///
/// If running in Rhino >7, Rhino7 will be used as fallback.
- /// when Rhino 7 is running, otherwise.
- public static string GetVersionedAppName()
- {
- var version = HostApplications.Grasshopper.GetVersion(HostAppVersion.v6);
- if (RhinoApp.Version.Major >= 7)
- {
- version = HostApplications.Grasshopper.GetVersion(HostAppVersion.v7);
- }
-
- return version;
- }
+ /// when Rhino 7 is running, when Rhino 8 is running, otherwise.
+ [Obsolete("Use Loader.GetGrasshopperHostAppVersion instead")]
+ public static string GetVersionedAppName() => Loader.GetGrasshopperHostAppVersion();
public static ISpeckleConverter GetDefaultConverter()
{
diff --git a/ConnectorGrasshopper/ConnectorGrasshopperShared/Loader.cs b/ConnectorGrasshopper/ConnectorGrasshopperShared/Loader.cs
index 2084013717..7a2f00ab71 100644
--- a/ConnectorGrasshopper/ConnectorGrasshopperShared/Loader.cs
+++ b/ConnectorGrasshopper/ConnectorGrasshopperShared/Loader.cs
@@ -49,7 +49,8 @@ public override GH_LoadingInstruction PriorityLoad()
Setup.Init(GetRhinoHostAppVersion(), HostApplications.Rhino.Slug, logConfig);
Instances.CanvasCreated += OnCanvasCreated;
-#if RHINO7
+
+#if RHINO7_OR_GREATER
if (Instances.RunningHeadless)
{
// If GH is running headless, we listen for document added/removed events.
@@ -492,7 +493,7 @@ public static void KeepOpenOnDropdownCheck(ToolStripMenuItem ctl)
public static void DisposeHeadlessDoc()
{
-#if RHINO7
+#if RHINO7_OR_GREATER
_headlessDoc?.Dispose();
#endif
_headlessDoc = null;
@@ -500,7 +501,7 @@ public static void DisposeHeadlessDoc()
public static void SetupHeadlessDoc()
{
-#if RHINO7
+#if RHINO7_OR_GREATER
// var templatePath = Path.Combine(Helpers.UserApplicationDataPath, "Speckle", "Templates",
// SpeckleGHSettings.HeadlessTemplateFilename);
// Console.WriteLine($"Setting up doc. Looking for '{templatePath}'");
@@ -510,7 +511,8 @@ public static void SetupHeadlessDoc()
_headlessDoc = RhinoDoc.CreateHeadless(null);
Console.WriteLine(
- $"Headless run with doc '{_headlessDoc.Name ?? "Untitled"}'\n with template: '{_headlessDoc.TemplateFileUsed ?? "No template"}'\n with units: {_headlessDoc.ModelUnitSystem}");
+ $"Speckle - Backup headless doc is ready: '{_headlessDoc.Name ?? "Untitled"}'\n with template: '{_headlessDoc.TemplateFileUsed ?? "No template"}'\n with units: {_headlessDoc.ModelUnitSystem}");
+ Console.WriteLine("Speckle - To modify the units in a headless run, you can override the 'RhinoDoc.ActiveDoc' in the '.gh' file using a c#/python script.");
#endif
}
@@ -521,14 +523,18 @@ public static void SetupHeadlessDoc()
///
public static RhinoDoc GetCurrentDocument()
{
-#if RHINO7
- if (Instances.RunningHeadless && RhinoDoc.ActiveDoc == null)
+#if RHINO7_OR_GREATER
+ if (Instances.RunningHeadless && RhinoDoc.ActiveDoc == null && _headlessDoc != null)
{
+ // Running headless, with no ActiveDoc override and _headlessDoc was correctly initialised.
+ // Only time the _headlessDoc is not set is upon document opening, where the components will
+ // check for this as their normal initialisation routine, but the document will be refreshed on every solution run.
Console.WriteLine(
- $"Fetching headless doc '{_headlessDoc.Name ?? "Untitled"}'\n with template: '{_headlessDoc.TemplateFileUsed ?? "No template"}'");
+ $"Speckle - Fetching headless doc '{_headlessDoc?.Name ?? "Untitled"}'\n with template: '{_headlessDoc.TemplateFileUsed ?? "No template"}'");
Console.WriteLine(" Model units:" + _headlessDoc.ModelUnitSystem);
return _headlessDoc;
}
+
return RhinoDoc.ActiveDoc;
#else
return RhinoDoc.ActiveDoc;
diff --git a/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObject.cs b/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObject.cs
index fc9ecae967..3749d94648 100644
--- a/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObject.cs
+++ b/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObject.cs
@@ -186,7 +186,7 @@ public override void AddedToDocument(GH_Document document)
break;
}
(Params.Output[0] as SpeckleBaseParam).UseSchemaTag = UseSchemaTag;
-#if RHINO7
+#if RHINO7_OR_GREATER
if (!Instances.RunningHeadless)
{
(Params.Output[0] as SpeckleBaseParam).ExpirePreview(true);
diff --git a/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObjectBase.cs b/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObjectBase.cs
index 83897b862c..3c15340967 100644
--- a/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObjectBase.cs
+++ b/ConnectorGrasshopper/ConnectorGrasshopperShared/SchemaBuilder/CreateSchemaObjectBase.cs
@@ -243,7 +243,7 @@ public override void AddedToDocument(GH_Document document)
}
((SpeckleBaseParam)Params.Output[0]).UseSchemaTag = UseSchemaTag;
-#if RHINO7
+#if RHINO7_OR_GREATER
if (!Instances.RunningHeadless)
{
(Params.Output[0] as SpeckleBaseParam).ExpirePreview(true);