Grasshopper

algorithmic modeling for Rhino

I have been trying to understand a problem I have with selecting objects. I'm writing a plugin with an adjusted layer panel. The selection of object works, but in Rhino the Gumball does not get updated. Also, if I'm in a command which requires selection of objects (e.g. BooleanDifference), it does not "see" that new object were selected.

 

If anybody could explain this to me it would be very appreciated.

Below is the function to select object on a specific layer.

 

private void ActionSelectAddObjects(object sender)
{
    // Get the layer that got clicked upon
    Layer l = LocivirRhinoLayerPanel_GetLayer(sender);
    // Do nothing if we could not get the layer
    if (l == null) return;
    // Get all objects on the layer
    Rhino.DocObjects.RhinoObject[] objs = RhinoDoc.ActiveDoc.Objects.FindByLayer(l);
    // If [Control] is pressed, unselect all object before selecting new objects
    if (Control.ModifierKeys == Keys.Control) RhinoDoc.ActiveDoc.Objects.UnselectAll();

// Check if there we got any objects returned
    if (objs != null)
    {
        // Rotate through the objects and select them if they are selectable
        foreach (RhinoObject obj in objs)
            RhinoDoc.ActiveDoc.Objects.Select(obj.Id, true);
    }
    // Reflect the selection changes in the viewports
    RhinoDoc.ActiveDoc.Views.Redraw();
    // Reset the focus to the main window
    RhinoApp.SetFocusToMainWindow();
}

Views: 1142

Replies to This Discussion

RhinoDoc.ActiveDoc.Objects.Select(obj.Id, true, true, true);

I think...

--

David Rutten

david@mcneel.com

Poprad, Slovakia

David,

Thank you for the suggestion but it does not work. I tried all the overloads that take a Guid already. When I select multiple objects like this and add another object to the selection (or with shift select an selected object again) rhino acts normally. The gumball shows up and running command take the selection.

Any other ideas?

Nope, sorry. 

You can post the question here: https://github.com/mcneel/rhinocommon/issues

It does seem like it might be a bug.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Rhino.DocObjects.RhinoObject[] objs = RhinoDoc.ActiveDoc.Objects.FindByLayer(Parameter);

foreach(Rhino.DocObjects.RhinoObject RO in objs)

{
RO.Select(true);

}


RhinoDoc.ActiveDoc.Views.Redraw();

this should work...

Michael,

The selection works fine. it's just that the Rhino does not get reflect the selection is changed. I posted this issue to GitHub, like David suggested. You can follow the discussion there: https://github.com/mcneel/rhinocommon/issues/144

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service