.NET

Reply
Active Contributor as
Active Contributor
as
Posts: 41
Registered: ‎04-27-2005
Message 1 of 10 (980 Views)

Selection Set in VB.Net

980 Views, 9 Replies
06-13-2005 04:01 AM
I trie to create as Selection set in VB.Net, if I do not use any filters it functions well, but when I trie to use the filter option I get an Error.

This is the code:

Friend Function SelectionSet_Create(ByVal Name As String, ByVal Point3dList() As Point3d, ByVal ObjectName As String) As AcadSelectionSet
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim SSObj As AcadSelectionSet
Dim SSmode As Autodesk.AutoCAD.Interop.Common.AcSelect
Dim PointsArray As Array = PointlistToArray(Point3dList)

Try
acadApp = CType(GetObject(, AutoCadApplicatie), AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True

SSObj = acadDoc.SelectionSets.Add(Name)
SSmode = Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetCrossingPolygon

If ObjectName "*" Then
Dim FilterType(0) As Integer : FilterType(0) = 2
Dim FilterData(0) As String : FilterData(0) = ObjectName
SSObj.SelectByPolygon(SSmode, PointsArray, FilterType, FilterData)
Else
SSObj.SelectByPolygon(SSmode, PointsArray)
End If

SSObj.Highlight(True)

Autodesk.AutoCAD.ApplicationServices.CommandLinePrompts.Message(vbCrLf & SSObj.Count & " Objects selected" + vbCrLf)

Catch ex As Exception
MessageBox.Show(ex.ToString)
Return Nothing

End Try
End Function

And this is the error I get is attached.

What is going wrong ?

Harold van Aarsen
The Netherlands
Active Contributor as
Active Contributor
as
Posts: 41
Registered: ‎04-27-2005
Message 2 of 10 (980 Views)

Re: Selection Set in VB.Net

06-13-2005 04:34 AM in reply to: as
I have replaced the text :

Dim FilterType(0) As Integer : FilterType(0) = 2
Dim FilterData(0) As String : FilterData(0) = ObjectName

with :

Dim FilterType() As Int16 = {2}
Dim FilterData() As Object = {"Hsb_DbElement"}

and now it functions well.
Active Contributor
tangferry
Posts: 43
Registered: ‎04-21-2005
Message 3 of 10 (980 Views)

Re: Selection Set in VB.Net

06-13-2005 08:56 PM in reply to: as
There is a bug in the managed wrapper class.You can use my DOTNETARX library to use the filter option in Selection sets.
Active Contributor
tangferry
Posts: 43
Registered: ‎04-21-2005
Message 4 of 10 (980 Views)

Re: Selection Set in VB.Net

06-13-2005 08:59 PM in reply to: as
I'm sorry,you use the com!You should replace
Dim FilterType(0) As Integer
with
Dim FilterType(0) As short
Active Contributor as
Active Contributor
as
Posts: 41
Registered: ‎04-27-2005
Message 5 of 10 (980 Views)

Re: Selection Set in VB.Net

06-13-2005 10:14 PM in reply to: as
You are right
*technosterone
Message 6 of 10 (980 Views)

Re: Selection Set in VB.Net

06-29-2005 04:12 AM in reply to: as
Hello, Harold!
What do you filter in your sample?
Active Contributor as
Active Contributor
as
Posts: 41
Registered: ‎04-27-2005
Message 7 of 10 (980 Views)

Re: Selection Set in VB.Net

06-29-2005 10:16 PM in reply to: as
In this case I wanted to select some HSBcad object, but the general goal was to create some functions wich I can use in more cases.

Beneath are the functions I created in VB.Net 2003

#Region " Selections Sets "

Friend Function SelectionSet_CreateWindow(ByVal Name As String, ByVal ObjectName As String) As AcadSelectionSet
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim SSObj As AcadSelectionSet
Try
acadApp = CType(GetObject(, AutoCadApplicatie), AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True

SSObj = acadDoc.SelectionSets.Add(Name)

Dim FilterType() As Int16 = {0}
Dim FilterData() As Object = {ObjectName}
SSObj.SelectOnScreen(FilterType, FilterData)

Return SSObj

Autodesk.AutoCAD.ApplicationServices.CommandLinePrompts.Message(vbCrLf & SSObj.Count & " Objects selected" + vbCrLf)

Catch ex As Exception
MessageBox.Show(ex.ToString)
Return Nothing

End Try
End Function

Friend Function SelectionSet_CreateAll(ByVal Name As String, ByVal ObjectName As String) As AcadSelectionSet
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim SSObj As AcadSelectionSet
Try
acadApp = CType(GetObject(, AutoCadApplicatie), AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True

SSObj = acadDoc.SelectionSets.Add(Name)

Dim FilterType() As Int16 = {0}
Dim FilterData() As Object = {ObjectName}
SSObj.Select(AcSelect.acSelectionSetAll, , , FilterType, FilterData)

Return SSObj

Autodesk.AutoCAD.ApplicationServices.CommandLinePrompts.Message(vbCrLf & SSObj.Count & " Objects selected" + vbCrLf)

Catch ex As Exception
MessageBox.Show(ex.ToString)
Return Nothing

End Try
End Function

Friend Function SelectionSet_Delete(ByVal Name As String) As Boolean
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim Obj As AcadSelectionSet
Dim Found As Boolean = False

Try
acadApp = CType(GetObject(, AutoCadApplicatie), AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True
For Each Obj In acadDoc.SelectionSets
If Obj.Name = Name Then Found = True
Next

If Found = True Then acadDoc.SelectionSets.Item(Name).Delete()

Return True

Catch ex As Exception
MessageBox.Show(ex.ToString)
Return False

End Try
End Function

#End Region
*technosterone
Message 8 of 10 (980 Views)

Re: Selection Set in VB.Net

07-03-2005 10:40 PM in reply to: as
Thank you, Harold.
Active Member
Naveen
Posts: 6
Registered: ‎07-12-2005
Message 9 of 10 (980 Views)

Re: Selection Set in VB.Net

07-21-2005 08:56 PM in reply to: as
Hi,
Since you are discussing about selectionset, I have a question regarding it. How can I make a selection set as pickfirst selection set using .NET API.

Thanks
Naveen.
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 10 of 10 (980 Views)

Re: Selection Set in VB.Net

04-13-2006 08:15 PM in reply to: as
when I try to get the selection set with this example I always get an error saying the AutoCAD window is invisible. Even if I set the visible state to true. Any idea what causes this error?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!