While looking at layer table methods for another thread, I came across this:
However, when trying to get an object’s layer via object attributes, there is no method currently available other than using the layer index…
The above statement in the RhinoCommon api guide then seems contradictory… If it really is the direction we are going, doesn’t object attributes need an additional property LayerId
?
2 Likes
dale
(Dale Fugier)
April 4, 2019, 3:45pm
2
@Helvetosaur , there is a different between “We are moving towards…” and “We have moved…”.
– Dale
Yep… but it you want to pave the way for the move, you need to provide the bricks…
I can provide some bricks the day when layer indices stop working and i have to rewrite everything
_
c.
n.leguina
(N Leguina)
May 17, 2020, 10:36pm
5
Hi
So if I want to set the layer to an object I understand I need to do it through the attributes.
But the attributes only takes layer index, and the method to obtain the layer index from the layer name is obsolete.
So how can I do this?
dale
(Dale Fugier)
May 18, 2020, 5:30pm
6
Hi @n.leguina ,
How about this:
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var layer_index = doc.Layers.FindByFullPath("MyLayer", 0);
var circle = new Circle(Plane.WorldXY, 5.0);
var attributes = doc.CreateDefaultAttributes();
attributes.LayerIndex = layer_index;
doc.Objects.AddCircle(circle, attributes);
doc.Views.Redraw();
return Result.Success;
}
– Dale