Controlling draw order with grasshopper

Quick question, is there any plugin to control draw order of rhino layers using grasshopper,

ie, can i command rhino to ‘BringToFront’ any layers or objects i specify

I.e, i am using Human to control plot weights and print color, would like to be able to control draw order also

thanks

I’ve wrote a little code that can help you achieve what you’re looking for:
Arkadius%20Belov

if(!run)
  return;
for(int i = 0; i < layers.Count; i++)
{
  Rhino.DocObjects.RhinoObject[] rhobjs = doc.Objects.FindByLayer(layers[i]);
  foreach(Rhino.DocObjects.RhinoObject rhobj in rhobjs)
  {
    rhobj.Attributes.DisplayOrder = i;
    rhobj.CommitChanges();
  }
}

Arkadius Belov.3dm (56.3 KB)
Arkadius Belov.gh (15.7 KB)

7 Likes

Thank you very much Mahdiyar,
the definition works as given,
and your presentation of it was very easy to understand

arkadius

Hi,

Thanks for the script. Is it possible to adapt it to work for sub-layers using the full layer path as well as layers?

Thank you!

Draworder Test

@Mahdiyar – Much appreciate the work you did. I have been testing it to see I can integrate into a workflow and cannot completely figure out what is going on but seems to not work with sublayers or really more layers than two. Any ideas here? (Revised test files linked).

Arkadius Belov_Coby Test.3dm (182.3 KB)
Arkadius Belov_Coby Test.gh (18.1 KB)

2023-02-05-14-05-03

private void RunScript(List<string> layers, bool run)
{
  if(!run) return;
  for(int i = 0; i < layers.Count; i++)
  {
    var layer = RhinoDocument.Layers.FindByFullPath(layers[i], -1);
    if (layer < 0) return;
    var rhobjs = doc.Objects.FindByLayer(RhinoDocument.Layers.FindIndex(layer));
    foreach(var rhobj in rhobjs)
    {
      rhobj.Attributes.DisplayOrder = i;
      rhobj.CommitChanges();
    }
  }
}

Arkadius Belov_Coby Test.gh (9.2 KB)

Rhino 8 has draw order as an attribute which can be assigned to objects. It’s part of the Drafting Attributes component.

1 Like