From the AutoDESK help docs (http://docs.autodesk.com/ACD/2013/EN...ber=d30e719293)
"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?
Norman Yuan
SelectionSet object is member of
Autodesk.AutoCAD.EditorInput namespace
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:
ThisDrawing.SelectionSets("SS1")
Show your Sub code to see what you started wth,
guess you want to use Interop library?
"If I create 2 selection sets ss1 and ss2, then how do I access one of these like:
ThisDrawing.SelectionSets("SS1")
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
Type:
Autodesk.AutoCAD.EditorInput
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?
Simply use List (Of Selectionset) but you did not extend
the number of SelectionSet more than 255
@NirantarVidyarthee wrote: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.
There is no need for a collection of SelectionSet in the .NET. API.
SelectionSets are things you get friom calling editor methods to select objects, and after you get them and do what you need with the objects they contain, you discard them.
Unlike ActiveX SelectionSets, managed SelectionSets are not re-usable. There is no Clear() method to empty them and there is no way to re-use them. Unlike ActiveX selection sets, managed selection sets do not have methods to select objects.The Editor class has those methods, and they return a new managed SelectionSet each time you call them, so there's really no point or purpose to having a collection of managed SelectionSets.
The ActiveX and managed APIs are not remotely similar, and I think that's the underlying problem here. You can't approach programming with the .NET API as if it were just a managed equivalent of the ActiveX API, because it is not. It is very different and more difficult to use, but more powerful at the same time.
Can't find what you're looking for? Ask the community or share your knowledge.