When you get a selection set from the user, how are the items stored. Are they stored as Objects or as whatever they are ??? Is a selection set an array of objects?? I cant find much on this topic.
Here is some code. It is a simple little macro that is supposed to isolate a single layer and turn all other off. If anyone can help, please do.
Some of this is pseudocode:
1 Sub Isolate()
2 Dim myLayer As AcadLayer
3 Dim Selection As AcadSelectionSet
4
5 Create SelectionSet
6 Let user select an item in the current drawing
7
8 'Here is where I need help. I am not sure how to figure out what layer
9 'the object is on.
10 Set myLayer = Selection(0).Layer
11
12 MsgBox "Item is on layer" & Selection(0).Layer
13
14 For Each Layer is ThisDrawing
15 If Layer = myLayer Then Layer should be on
16 Else Layer should be off.
17 Next
18
19 End Sub
The funny thing is that line #10 gives me an error, but line 12 doesn't. Line 12 will print correctly and tell me what layer the user selected object is on. Why won't line 10 work. Also, line 14 doesn't work. I don't think I can use "ThisDrawing". My main concern is that I don't understand the internal storage of a selection set. How is each item stored and how is each item accessed. Are they indexed. Do I need to take them out of the selction set before manipulating them.
I have looked extensively for information on this subject but I can find none. Please help. If you know any good tutorials or books on this subject please let me know. Thanks
Here is some code. It is a simple little macro that is supposed to isolate a single layer and turn all other off. If anyone can help, please do.
Some of this is pseudocode:
1 Sub Isolate()
2 Dim myLayer As AcadLayer
3 Dim Selection As AcadSelectionSet
4
5 Create SelectionSet
6 Let user select an item in the current drawing
7
8 'Here is where I need help. I am not sure how to figure out what layer
9 'the object is on.
10 Set myLayer = Selection(0).Layer
11
12 MsgBox "Item is on layer" & Selection(0).Layer
13
14 For Each Layer is ThisDrawing
15 If Layer = myLayer Then Layer should be on
16 Else Layer should be off.
17 Next
18
19 End Sub
The funny thing is that line #10 gives me an error, but line 12 doesn't. Line 12 will print correctly and tell me what layer the user selected object is on. Why won't line 10 work. Also, line 14 doesn't work. I don't think I can use "ThisDrawing". My main concern is that I don't understand the internal storage of a selection set. How is each item stored and how is each item accessed. Are they indexed. Do I need to take them out of the selction set before manipulating them.
I have looked extensively for information on this subject but I can find none. Please help. If you know any good tutorials or books on this subject please let me know. Thanks