From the AutoDESK help docs (http://docs.autodesk.com/ACD/2013/EN...ber=d30e719
"AutoCAD.Application.ActiveDocument.SelectionSets. Add method
Not needed/provided" in VB.Net
Thus 'Autodesk.AutoCAD.ApplicationServices.Application. DocumentManager.MdiActiveDocument.SelectionSets' will not work.
So, I can't store multiple selection sets in VB.Net?
Why is it not provided? Or is there some other way to do that?
It seems you do not know the difference of programming language (VB.NET/C#...) and AutoCAD APIs (COM API/.NET API).
AutoCAD.Application.ActiveDocument.SelectionSets. Add() still exists in COM API and can be used when needed. With AutoCAD .NET programming (VB.NET/C#), AutoCAD .NET API usually provides enough functionlities, but you can easily mix COM API calls in it (in many cases it is not necesary, as you quoted!).
So, what do you do that you have to use "AutoCAD.Application.ActiveDocument.SelectionSets. Add()", instead of various selecting methods provided in .NET API?
SelectionSet object is member of
Obviusly, I don't know the difference between VB and VBA. That;s the reason I came here and asked the question.
But my original quesry remains: How can I access the SelectionSets collection (or its equivalent) in VB.Net.
If I create 2 selection sets ss1 and ss2, then how do I access one of these like:
Show your Sub code to see what you started wth,
guess you want to use Interop library?
I didn't see your code, well, then try my attempt
<CommandMethod("testAcadSelections")> _ Public Shared Sub testSelections() '' borrowed from Luis Esquivel Dim AcadComApp As AcadApplication = Nothing Dim progId As String = "AutoCAD.Application.18" '' <-- AutoCAD 2010 Try ' Get a current instance of AutoCAD AcadComApp = TryCast(GetObject(, progId), AcadApplication) Catch ex As System.Exception Try ' Create a new instance of AutoCAD AcadComApp = TryCast(CreateObject(progId), AcadApplication) Catch exx As Exception MsgBox(exx.Message) Exit Sub End Try End Try Try ' Get the active document Dim AcadComDoc As AcadDocument = TryCast(AcadComApp.ActiveDocument, AcadDocument) ' Get AcadSelectionSets collection Dim AcadSets As AcadSelectionSets = TryCast(AcadComDoc.SelectionSets, AcadSelectionSets) ' Declare AcadSelectionSet Dim AcadSsetObj As AcadSelectionSet = Nothing ' Get a StringBuilder object Dim sb As StringBuilder = New StringBuilder ' Add some selections to document For i As Integer = 0 To 24 Dim setName As String = "Selection" & (i + 1).ToString() AcadSsetObj = AcadSets.Add(setName) sb.AppendLine(AcadSsetObj.Name) Next MsgBox("Number of selections created: " & AcadSets.Count.ToString() & vbLf & sb.ToString()) Dim layoutName As String = AcadComDoc.GetVariable("ctab").ToString() ' Get the very first selection AcadSsetObj = AcadSets.Item(0) ' Create filter to select attributed blocks on current layout Dim filterType(2) As Short filterType(0) = 0 filterType(1) = 66 filterType(2) = 410 Dim filterData(2) As Object filterData(0) = "insert" filterData(1) = 1 filterData(2) = layoutName ' Perform the Select method AcadSsetObj.Select(AcSelect.acSelectionSetAll, , , filterType, filterData) ' Display result MsgBox("First selection:" & vbLf & "Number of block selected: " & AcadSsetObj.Count.ToString()) Catch aex As System.Exception MsgBox(aex.Message & vbLf & aex.StackTrace) Finally ' AcadComApp.Quit() AcadComApp = Nothing End Try End Sub
See for more
Thankyou but my question is not about how we can use COM API for getting SelectionSets collection. My question is why .NET API does not provide this and is there any other way in .NET API, other than probably creating my own collection.
My answer is in post#3 if you don't understand it
in editor console,
then highlight it and select from right clicking mouse: Go to Definition,
then scroll down to see Selection within object Browser
You can see so there is no SelectionSets collection in there
just only SelectionSet object only, and also read the docs for more
" You can see so there is no SelectionSets collection in there
just only SelectionSet object only, and also read the docs for more."
I know this.And I stated this in my first post.
I am asking why? What could be the logical reason behind not having the collection? And is using COM API the only alternative?
Access a broad range of knowledge to help get the most out of your products and services.