Determine if Rhino document is in block edit mode

        private static PlugIn plugin;
        private static Type editorType;
        private static MethodInfo methodTryGet;
        private static PropertyInfo propertyIsInplace;
        private static bool CacheReflection()
        {
            if (plugin != null && editorType != null && methodTryGet != null && propertyIsInplace != null)
                return true;

            plugin = PlugIn.Find(new Guid("f2231a2f-66bf-4558-94ce-988c15aede65"));
            if (plugin == null)
                return false;
            editorType = plugin.GetType().Assembly.GetType("BlockEdit.Editor", true);
            methodTryGet = editorType.GetMethod("TryGet", new[] { typeof(RhinoDoc) });
            propertyIsInplace = editorType.GetProperty("InPlaceEditIsRunning");
            return true;
        }
        public static bool IsInBlockEditMode()
        {
            if (!CacheReflection())
                return false;
            
            var editor = methodTryGet.Invoke(null, new[] { RhinoDoc.ActiveDoc });

            if (editor == null)
                return false;
            return (bool)propertyIsInplace.GetValue(editor);
        }
1 Like