From d219aba68bf76d3efa8b37bc6444680a7ce3e5ea Mon Sep 17 00:00:00 2001 From: eirannejad Date: Thu, 7 Nov 2024 12:05:28 -0800 Subject: [PATCH] Fixed missing recursion key Exception --- src/hops/HopsComponent.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hops/HopsComponent.cs b/src/hops/HopsComponent.cs index 2aabec5d..6192f917 100644 --- a/src/hops/HopsComponent.cs +++ b/src/hops/HopsComponent.cs @@ -17,6 +17,7 @@ using Rhino; using System.Drawing; using Grasshopper; +using Grasshopper.Kernel.Expressions; namespace Hops { @@ -88,12 +89,15 @@ protected override void BeforeSolveInstance() _enabledThisSolve = true; _lastCreatedSchema = null; _solveRecursionLevel = 0; - var doc = OnPingDocument(); - if (_isHeadless && doc != null) + if (_isHeadless && + OnPingDocument() is GH_Document doc) { - // compute will set the ComputeRecursionLevel - _solveRecursionLevel = doc.ConstantServer["ComputeRecursionLevel"]._Int; + if (doc.ConstantServer.TryGetValue("ComputeRecursionLevel", out GH_Variant recursionLevel)) + // compute will set the ComputeRecursionLevel + _solveRecursionLevel = recursionLevel._Int; + else + _solveRecursionLevel = HopsAppSettings.RecursionLimit; } if (!_solvedCallback)