.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.acSelecti onSetCrossingPolygon
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.CommandLinePr ompts.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
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.acSelecti
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.CommandLinePr
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
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
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.
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
Dim FilterType(0) As Integer
with
Dim FilterType(0) As short
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-13-2005 10:14 PM in reply to:
as
You are right
*technosterone
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-29-2005 04:12 AM in reply to:
as
Hello, Harold!
What do you filter in your sample?
What do you filter in your sample?
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.CommandLinePr ompts.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.CommandLinePr ompts.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
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.CommandLinePr
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.CommandLinePr
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
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-03-2005 10:40 PM in reply to:
as
Thank you, Harold.
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
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.
Re: Selection Set in VB.Net
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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?
