• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Contributor as
    Active Contributor
    Posts: 41
    Registered: ‎04-27-2005

    Selection Set in VB.Net

    721 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
    Please use plain text.
    Active Contributor as
    Active Contributor
    Posts: 41
    Registered: ‎04-27-2005

    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.
    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎04-21-2005

    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.
    Please use plain text.
    Active Contributor
    Posts: 43
    Registered: ‎04-21-2005

    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
    Please use plain text.
    Active Contributor as
    Active Contributor
    Posts: 41
    Registered: ‎04-27-2005

    Re: Selection Set in VB.Net

    06-13-2005 10:14 PM in reply to: as
    You are right
    Please use plain text.
    *technosterone

    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?
    Please use plain text.
    Active Contributor as
    Active Contributor
    Posts: 41
    Registered: ‎04-27-2005

    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
    Please use plain text.
    *technosterone

    Re: Selection Set in VB.Net

    07-03-2005 10:40 PM in reply to: as
    Thank you, Harold.
    Please use plain text.
    Active Member
    Posts: 6
    Registered: ‎07-12-2005

    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.
    Please use plain text.
    Contributor
    Posts: 17
    Registered: ‎01-27-2005

    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?
    Please use plain text.