Determine if Rhino document is in block edit mode

Hello,

I am trying to figure out programmatically if the current Rhino Doc is in Block edit mode.

Subscribing to the command event I can tell if the edit mode started or if OK was pressed afterwards. If the user closes the dialog cancelling the changes, I cannot find a way to tell it was closed.
I’ve also figured out BlockEdit is a plugin.

These results lead to 404 git pages. @dale can you shed some light please? Would much appreciate.

image

@JohnM - Do you know anything about this?

@dale I’m pretty sure that got removed.

        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

I want to add that another way to do this is to use the Eto.Forms.Application.Instance.Windows to get a list that will include the block edit panel (if its open). Once you have the panel you can then add an event handler to the “Closed” event to tell you when you have left the block editor (either from pressing x or OK).