Hi all,
I’m trying to get all points in my current doc using .FindByObjectType(ObjectType.Point).
My problem is I get points only from current layer. How can get points from all the layers ?
Thanks for your help
Damien
Hi all,
I’m trying to get all points in my current doc using .FindByObjectType(ObjectType.Point).
My problem is I get points only from current layer. How can get points from all the layers ?
Thanks for your help
Damien
This seem to work:
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
RhinoObject[] objs = doc.Objects.FindByObjectType(ObjectType.Point);
foreach (RhinoObject obj in objs)
{
PointObject point_obj = obj as PointObject;
if (null != point_obj)
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format("Point = {0}", point_obj.PointGeometry.Location.ToString()));
sb.Append(", ");
sb.Append(string.Format("Layer = {0}", doc.Layers[point_obj.Attributes.LayerIndex].Name));
RhinoApp.WriteLine(sb.ToString());
}
}
return Result.Success;
}
Let me know if you find otherwise.
Hi Dale,
Problem with the way you suggest me is your RhinoObject[] objs contains only Object from the current layer. I need to get points from all the layers.
Thanks
Damien
Then you must use the ObjectEnumeratorSettings:
ObjectEnumeratorSettings settings = new ObjectEnumeratorSettings
{
NormalObjects = true,
HiddenObjects = true, // will also select hidden objects!
ObjectTypeFilter = ObjectType.Point
};
IEnumerable<RhinoObject> list = Document.Objects.GetObjectList(settings);
Have you tried the code? Here is some sample output. Note the different layers…
Point = 9.70185670353392,4.85092835176696,0, Layer = Layer 02
Point = 9.8958938376046,8.24657819800383,0, Layer = Layer 02
Point = 3.68670554734289,1.84335277367144,0, Layer = Layer 01
Point = 3.29863127920154,5.04496548583764,0, Layer = Layer 01
Point = -7.17937396061509,-0.388074268141357,0, Layer = Default
Point = -4.07477981548424,3.97776124844891,0, Layer = Default
Hi Dale,
Your code works only if all the layers are activated with the bulb. I’m trying to find points even if the layers are unactivated. Is it possible ?
Thanks
Damien
Menno,
Your solution seems to be the right one to find hidden object. I’m gonna try with this.
Regards
Damien
I know it can be difficult, but it is always best if you can provide all information. It sure saves a lot of time and effort…
Yes, my code only works on active layers - this is by design…
Sorry Dale !
I’ll do better next time !
Thanks
Damien