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)

4 Likes

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

3 Likes

@AndyPayne Draw order in Rhino 8 is great! Thank you for that!

Question regarding Draw Order in GH, it appears to work well with text objects such as annotations, text, text dots, lines, etc. However, when I try to use it with a data tree of trimmed surfaces it only works on the first surface (seems like a data tree mismatch right?.. well I checked that and I don’t think it is? Regardless of how I structure the data, it appears to only show the draw order properly on the first surface. I’ve tested with baking and custom preview and both yield same results. Am I overlooking something obvious?

Thank you for your help!

1 Like

Hi Michael -

Only that draw order doesn’t work for surfaces. This is strictly for curves, annotations, and hatches.
-wim

Understood, so the fact the one surface I have that is coming through is just a fluke?

I guess the proper method is I use these surface boundary polylines as hatch boundaries, and then give a solid fill to each hatch matching the colors above, and then apply draw order of 1 to the model hatch objects.

Am I thinking correctly in that regard?

Thanks for the info!

Hi Michael -

Yes, with hatch objects, you can control the draw order.
-wim

We’re sorry that we didn’t know your worth the way we should know. Your answers are incredibly helpful.

1 Like