to select object on a single layer
Dim strLayer as string = "road" acTypValAr.SetValue(New TypedValue(DxfCode.LayerName, strLayer), 2)
how do you select all objects on multiple layers
Dim strLayer as string = "road,sidewalks" acTypValAr.SetValue(New TypedValue(DxfCode.LayerName, strLayer), 2)
the above does not work. any suggestions how do you select all objects on multiple layers?
Hi,
what is the question or what is not clear? To select all objects on layer "road" and all objects on layer "sidewalks" you can use the statement you showed in the second code-snippet.
Or do I misinterpret your question?
- alfred -
Try this code, tested on A2009
<CommandMethod("multlayers", CommandFlags.UsePickSet And CommandFlags.Redraw)> _ Public Sub SortManyLayers() Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Dim height As Double = 0.2 Dim color As Integer = 256 Dim tid As ObjectId = ObjectId.Null Dim ar As New ArrayList() Dim tr As Transaction = db.TransactionManager.StartTransaction() Using tr Try Dim pso As PromptSelectionOptions = New PromptSelectionOptions pso.MessageForRemoval = vbLf + "Select circles only" pso.MessageForAdding = vbLf + "Select circles" Dim tv As TypedValue() = New TypedValue() {New TypedValue(0, "circle"), New TypedValue(8, "0,BORDER-A,BORDER-B,BORDER-E1")} Dim flt As New SelectionFilter(tv) Dim res As PromptSelectionResult res = ed.GetSelection(pso, flt) If res.Status <> PromptStatus.OK Then Return End If Dim sset As SelectionSet = res.Value Dim n As Integer = 0 For Each obj As SelectedObject In sset Dim dbobj As DBObject = tr.GetObject(obj.ObjectId, OpenMode.ForRead) Dim circ As Circle = TryCast(dbobj, Circle) If circ IsNot Nothing Then 'If n = 0 Then Dim pt As Point3d = circ.Center Dim cid As ObjectId = circ.ObjectId Dim kp As New KeyValuePair(Of ObjectId, Point3d)(cid, pt) ar.Add(kp) 'End If End If Next ed.WriteMessage(vbLf & "Count Circles = " + ar.Count.ToString()) tr.Commit() Catch ex As System.Exception ed.WriteMessage(ex.ToString) Finally For Each kp As KeyValuePair(Of ObjectId, Point3d) In ar ed.WriteMessage(vbLf + "ObjectID: {0}" + vbTab + "Center Point: {1}", kp.Key, kp.Value) Next End Try End Using End Sub
~'J'~
Thanks Alfred
I am working way too late into the night.
In this case I need to wipe the egg of my face.
I had an error in my code in regards to my layer name, spelling. UG!!!!!!.....sorry.
so yes "Road,Sidewalks" will select all objects on layer Roads and objects on layer Sidewalks.
thanks
HI
I"m not expert, but i'm not sure that it will. how will autocad know that the comma acts as an OR operator (||)
Kean W has answered your exact question in a comment in the post below:
http://through-the-interface.typepad.com/through_the_interface/2008/05/finding-all-the.html
gluckand i hope this helps.
rgds
BK
The "," is an illegal (layer) name character. Try creating a new layer using the input "a,b". It will create two layers: a and b.
Also the "|" is an illegal character, it's reserved to separate the current drawing layername with the Xref layername.
Both methodes
1. Name1, name2
2. OR Name1, Name2, ...
can be used to select items from several layers.
Hi,
All string value in selection filter TypedValueS as DxfCode.LayerName (8), DxfCode.Start (0), DxfCode.BlockName (2), and so on, can use wildcard patterns.
Have a look at the help docs:
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-3C1A759C-BB88-41A7-B1DE-697C493C92C8
Can't find what you're looking for? Ask the community or share your knowledge.