Highlighting objects on a layer


#1

This approach doesn’t work. Can anyone explain why?

                            doc.Objects.FindByLayer(doc.Layers[LayerId]);
                            doc.Views.Redraw();
                            MessageBox.Show("That layer already exists.  Parts on it have been hilighted,");

(Dale Fugier) #2

What are you trying to do? Or, what do you think this code should do?


#3

It should select everything on the layer doc.layers[LayerId] and highlight them.


(Dale Fugier) #4

A little more work is involved, as FindByLayer returns a list of objects. But you still need to iterate the list and select them.

Here is some code you can use as an example.

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsSelectLayerObjects.cs