.NET

Reply
*Nate Hunter
Message 1 of 2 (194 Views)

Attributes & Selection Sets with differnt OS

194 Views, 1 Replies
03-03-2006 11:04 AM
I am having a problem with Attributes and Selection Sets running on differnt
Operating systems. All XP Machines the below code will work but all 2000
machines will error out on:
atts = ss.Item(i).GetAttributes

The error I receive is:
System.Runtime.InteropServices.COMException (0x80020008): Bad variable type.
(Exception from HRESULT: 0x80020008 (DISP_E_BADVARTYPE))

Any Ideas how I can run the code on both Operating Systems.

Dim fType(2) As Short, fData(2) As Object, atts As Object
Dim ss As Autodesk.AutoCAD.Interop.AcadSelectionSet

Try
ss = ThisDrawing.SelectionSets.Add("ss")
Catch ex As Exception
ss = ThisDrawing.SelectionSets.Add("ss2")
End Try
ss.Clear()
fType(0) = 0 : fData(0) = "INSERT"
fType(1) = 2 : fData(1) = "Sheet Text 30x42"
fType(2) = 8 : fData(2) = "A-Tblk-Text"
ss.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, , ,
fType, fData)
For i = 0 To ss.Count - 1
atts = ss.Item(i).GetAttributes 'errors out here on Windows 2000
machines
'Do stuff with atts
Next i
Distinguished Contributor
cgay
Posts: 125
Registered: ‎08-02-2005
Message 2 of 2 (194 Views)

Re: Attributes & Selection Sets with differnt OS

03-03-2006 02:39 PM in reply to: *Nate Hunter
Nate,

Try this:

[code]
Dim ss As Autodesk.AutoCAD.Interop.AcadSelectionSet = Nothing

Try
ss = ThisDrawing.SelectionSets.Add("ss")
Catch ex As Exception
ss = ThisDrawing.SelectionSets.Item("ss")
ss.Clear()
End Try
If Not ss Is Nothing Then
Dim fType(2) As Short, fData(2) As Object
fType(0) = 0 : fData(0) = "INSERT"
fType(1) = 2 : fData(1) = "Sheet Text 30x42"
fType(2) = 8 : fData(2) = "A-Tblk-Text"
ss.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, , , fType, fData)

For Each aEnt As Autodesk.AutoCAD.Interop.Common.AcadEntity In ss
Dim atts As Object = Nothing
Select Case True
Case TypeOf aEnt Is Autodesk.AutoCAD.Interop.Common.AcadBlockReference
Dim acdBlock As Autodesk.AutoCAD.Interop.Common.AcadBlockReference = _
DirectCast(aEnt, Autodesk.AutoCAD.Interop.Common.AcadBlockReference)
atts = acdBlock.GetAttributes
Case TypeOf aEnt Is Autodesk.AutoCAD.Interop.Common.AcadExternalReference
Dim acdExtRef As Autodesk.AutoCAD.Interop.Common.AcadExternalReference = _
DirectCast(aEnt, Autodesk.AutoCAD.Interop.Common.AcadExternalReference)
atts = acdExtRef.GetAttributes
Case TypeOf aEnt Is Autodesk.AutoCAD.Interop.Common.AcadMInsertBlock
Dim acdMBlock As Autodesk.AutoCAD.Interop.Common.AcadMInsertBlock = _
DirectCast(aEnt, Autodesk.AutoCAD.Interop.Common.AcadMInsertBlock)
atts = acdMBlock.GetAttributes
Case Else
Debug.Assert(False, "Unhandled Type in selection set, " & TypeName(aEnt))
End Select
If Not atts Is Nothing Then
'Do stuff with atts
End If
Next
Else
MsgBox("Unable to obtain selection set", _
MsgBoxStyle.ApplicationModal Or _
MsgBoxStyle.Exclamation Or _
MsgBoxStyle.OkOnly, "Selection Set Error")
End If
[/code]
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.