Select Rhino objects created by extrusion when you also have pre selected objects

Hi, the issue is like this I have a function that has as input a ObjRef array an inside this function I would like to update the selection by removing or adding other objects to the array, my function is working fine with Curves but if I will create some objects using extrude and I will use those there will be a strange behavior, First thing is that my pre selected objects can only be deselected only after I first select them again, even if those are already highlighted as selected, can not use multiple selection to deselect also. And another strange thing is that if I will select an object(ex: a cube) by a face and I will try to deselect it by clicking on another face it will not work, I need to deselect using same selection face. I will also pot my function code below so, from what I read there are some issues with extruded objects but can anybody suggest a workaround to solve this. Thanks.

public void SelecRhinoObjects(ref Rhino.DocObjects.ObjRef[] objRefs)
        {
            Objects.UnselectAll();
            if (objRefs != null)
            {
                Objects.Select(objRefs);
                RhinoDoc.Views.Redraw();
            }
            GetObject go = new GetObject();
            go.SetCommandPrompt("Select objects");
            go.GeometryFilter = ObjectType.AnyObject;
            go.GroupSelect = true;
            go.SubObjectSelect = false;
            go.EnableClearObjectsOnEntry(false);
            go.EnableUnselectObjectsOnExit(false);
            go.DeselectAllBeforePostSelect = false;

            bool bHavePreselectedObjects = false;

            for (;;)
            {
                Rhino.Input.GetResult res = go.GetMultiple(1, 0);

                if (go.ObjectsWerePreselected)
                {
                    bHavePreselectedObjects = true;
                    go.EnablePreSelect(false, true);
                    go.AlreadySelectedObjectSelect = true;
                    continue;
                }

                break;
            }

            if (bHavePreselectedObjects)
            {
                for (int i = 0; i < go.ObjectCount; i++)
                {
                    Rhino.DocObjects.RhinoObject rhinoObject = go.Object(i).Object();
                    if (null != rhinoObject)
                        rhinoObject.Select(false);
                }
                Util.Redraw();
            }

            if (go.Objects() != null && go.Objects().Any())
                objRefs = go.Objects();
            else
                objRefs = null;
        }

Hi @raduh82,

Please review the following sample and let me know if you have any questions.

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinocommon/cs/SampleCsCommands/SampleCsPrePostSelect.cs

– Dale

1 Like