.NET

Reply
Valued Contributor
dbp428
Posts: 67
Registered: ‎03-09-2004
Message 1 of 4 (162 Views)

Attibutes VB.net 2003 ACAD 2006

162 Views, 3 Replies
12-26-2005 07:49 AM
I am getting an error on a line lower in the code as follows:
An unhandled exception of type ’System.ArgumentException’ occurred in WaterTank.exe
Additional information: Invalid argument FilterType in Select

Here is my code:
Dim A2K As Autodesk.AutoCAD.Interop.AcadApplication
Try
A2K = GetObject(, "AutoCAD.Application")
Catch
A2K = CreateObject("AutoCAD.Application")
End Try
Dim A2Kdwg As Autodesk.AutoCAD.Interop.AcadDocument = A2K.ActiveDocument
A2K.Visible = True
Dim ss As Autodesk.AutoCAD.Interop.AcadSelectionSet
Dim fType(1) As Single, fData(1) As Object

Dim i, j As Integer
Dim hndl, atts, NumBlocks As Object
Try
ss = A2Kdwg.SelectionSets.Add("ss")
Catch
'ss.Clear()
A2Kdwg.SelectionSets.Item("ss").Delete()
ss = A2Kdwg.SelectionSets.Add("ss")
End Try

ss.Clear()
fType(0) = CSng(0)
fType(1) = CSng(2)
fData(0) = "INSERT"
fData(1) = "REVISION BLOCK"

<<<<<<<<<<<<< GETTING ERROR ON THE FOLLOWING LINE >>>>>>>>
ss.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, , , fType, fData)

For i = 0 To ss.Count - 1 'This is how many times the Block exists in the drawing.
hndl = ss.Item(i).Handle
atts = ss.Item(i).GetAttributes
For j = LBound(atts) To UBound(atts) 'This is how many TAGS in a block
'
Debug.Write("Tag: " & atts(j).TagString & " Value: " & atts(j).TextString)
Next
Next
End Sub
*Tony Tanzillo
Message 2 of 4 (162 Views)

Re: Attibutes VB.net 2003 ACAD 2006

12-27-2005 12:57 PM in reply to: dbp428
>> Dim fType(1) As Single

A 'Single' is a single-precision floating point number.

Try Short or Int16 instead.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5045675@discussion.autodesk.com...
I am getting an error on a line lower in the code as follows:
An unhandled exception of type ’System.ArgumentException’ occurred in WaterTank.exe
Additional information: Invalid argument FilterType in Select

Here is my code:
Dim A2K As Autodesk.AutoCAD.Interop.AcadApplication
Try
A2K = GetObject(, "AutoCAD.Application")
Catch
A2K = CreateObject("AutoCAD.Application")
End Try
Dim A2Kdwg As Autodesk.AutoCAD.Interop.AcadDocument = A2K.ActiveDocument
A2K.Visible = True
Dim ss As Autodesk.AutoCAD.Interop.AcadSelectionSet
Dim fType(1) As Single, fData(1) As Object

Dim i, j As Integer
Dim hndl, atts, NumBlocks As Object
Try
ss = A2Kdwg.SelectionSets.Add("ss")
Catch
'ss.Clear()
A2Kdwg.SelectionSets.Item("ss").Delete()
ss = A2Kdwg.SelectionSets.Add("ss")
End Try

ss.Clear()
fType(0) = CSng(0)
fType(1) = CSng(2)
fData(0) = "INSERT"
fData(1) = "REVISION BLOCK"

<<<<<<<<<<<<< GETTING ERROR ON THE FOLLOWING LINE >>>>>>>>
ss.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, , , fType, fData)

For i = 0 To ss.Count - 1 'This is how many times the Block exists in the drawing.
hndl = ss.Item(i).Handle
atts = ss.Item(i).GetAttributes
For j = LBound(atts) To UBound(atts) 'This is how many TAGS in a block
'
Debug.Write("Tag: " & atts(j).TagString & " Value: " & atts(j).TextString)
Next
Next
End Sub
Valued Contributor
dbp428
Posts: 67
Registered: ‎03-09-2004
Message 3 of 4 (162 Views)

Re: Attibutes VB.net 2003 ACAD 2006

12-31-2005 01:28 PM in reply to: dbp428
Tony that did not fix it.
Which Reference(s) should I bee using? I am using:
Autodesk.AutoCAD.Interop
Autodesk.AutoCAD.Interop.Common

Also this is the Student version.
It opens the drawing OK and seems to get the selection set
But fails on the last line
Here is new code
---------------------
Dim A2K As Autodesk.AutoCAD.Interop.AcadApplication
Try
A2K = GetObject(, "AutoCAD.Application")
Catch
A2K = CreateObject("AutoCAD.Application")
End Try
Dim A2Kdwg As Autodesk.AutoCAD.Interop.AcadDocument = A2K.ActiveDocument
A2K.Visible = True
A2Kdwg.Application.Documents.Open(Label2.Text)
Dim ss As Autodesk.AutoCAD.Interop.AcadSelectionSet
' Dim fType(1) As Int16, fData(1) As Object
Dim fType As Int16 = 0
Dim fData As Object = "B-AttributeBlock"

Dim i, j As Integer
Dim hndl, atts, NumBlocks As Object
Try
ss = A2Kdwg.SelectionSets.Add("ss")
Catch
'ss.Clear()
A2Kdwg.SelectionSets.Item("ss").Delete()
ss = A2Kdwg.SelectionSets.Add("ss")
End Try

ss.Clear()
ss.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, , fType, fData)
-----------------------------
full error message
An unhandled exception of type 'System.ArgumentException' occurred in WaterTank2.exe

Additional information: Invalid argument FilterType or FilterData in Select
Valued Contributor
dbp428
Posts: 67
Registered: ‎03-09-2004
Message 4 of 4 (162 Views)

Re: Attibutes VB.net 2003 ACAD 2006

12-31-2005 02:28 PM in reply to: dbp428
>>>>>>>> OK I got it to work <<<<<<<<<<<<<
this code gets a drawing already loaded.
Loops through each attribute in a Title block called B-AttributeBlock. adds them to a list box and then shows 4 of them in text boxes. also gets the drawing and path
You need these two References in VB.NET
AutoCAD = Autodesk.AutoCAD.Interop
AXDBLib = Autodesk.AutoCAD.Interop.Common

------------------
Private Sub btnLoadAttributes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadAttributes.Click
Dim AcadObj As Object
Dim Path1, dwg As String
Dim OldtitleBlock As Object
Dim ThisDrawing As Object
Dim a, b, I, j, FindSlash As Integer

'OLE Automation Object Calls
AcadObj = GetObject(, "AutoCAD.Application")
ThisDrawing = AcadObj.ActiveDocument

OldtitleBlock = False

Dim docName As String
docName = ThisDrawing.FullName
b = 1
For a = 1 To Len(docName)
FindSlash = InStr(b, docName, "\")
If FindSlash = 0 Then Exit For
b = FindSlash + 1
Next

Path1 = Microsoft.VisualBasic.Left(docName, b - 1)
dwg = Microsoft.VisualBasic.Right(docName, Len(docName) - b + 1)

Dim fType(1) As Short, fData(1) As Object
Dim ss As Autodesk.AutoCAD.Interop.AcadSelectionSet
Try
ss = ThisDrawing.SelectionSets("ss")
Catch ex As Exception
ss = ThisDrawing.SelectionSets.Add("ss")
End Try

ss.Clear()
fType(0) = 0
fData(0) = "INSERT"
fType(1) = 2
fData(1) = "B-AttributeBlock"
ss.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, , , fType, fData)

' Now if the selection set count is greater than 0, you have every unnested instance of the block
' insert contained in the drawing. Since every item in the set is a BlockReference, you can use any
' property or method supported by AcadBlockReference and/or AcadEntity:
Dim hndl, atts As Object
For I = 0 To ss.Count - 1
OldtitleBlock = True
hndl = ss.Item(I).Handle
atts = ss.Item(I).GetAttributes
If VarType(atts) <> vbEmpty Then
For j = LBound(atts) To UBound(atts)
'
Me.lstAttributes.Items.Add(" Tag: " + atts(j).TagString + " Value: " + atts(j).TextString)
If atts(j).TagString = "QTYFORJOB" Then
If Val(atts(j).TextString) 0 Then
Me.txtQty.Text = atts(j).TextString
Else
MsgBox("The Job Qty is Zero, please key in a Quantity", vbInformation, "Missing Job Qty")

'GoTo Exit_Command16_Click
End If
End If
If atts(j).TagString = "TITLEBLCKSIZE" Then
If Microsoft.VisualBasic.Left(atts(j).TextString, 1) = "A" Then
'A size title block
Me.txtTitleBlock.Text = "A"
Else
' B size
Me.txtTitleBlock.Text = "B"
End If
End If
If atts(j).TagString = "THKXWIDXLNG" Then
Me.txtMaterialCutSize.Text = atts(j).TextString
End If
If atts(j).TagString = "MATERIALID" Then
Me.txtMaterialID.Text = atts(j).TextString
End If
Next
End If
Next
End Sub
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.