.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I don't get the TagString from Attributes

1 REPLY 1
Reply
Message 1 of 2
Anonymous
343 Views, 1 Reply

I don't get the TagString from Attributes

Hello,
I have a VB.NET-program. With the program I start AutoCAD 2007, open a
drawing and change the properties from attributes (COM-version).
I get a error in line "Console.WriteLine(DirectCast(objAcadObject,
Interop.Common.AcadAttribute).PromptString)".
What can I do?

Hartmut



Dim objBlock As Interop.Common.AcadBlock = Nothing
Dim objAcadEntity As Interop.Common.AcadEntity = Nothing
Dim objAcadBlockReference As Interop.Common.AcadBlockReference = Nothing
Dim obj() As Object = Nothing
Dim objAcadObject As Interop.Common.AcadObject = Nothing


For Each objBlock In objActiveDocument.Blocks
For Each objAcadEntity In objBlock
If objAcadEntity.ObjectName.ToLower = "AcDbBlockReference".ToLower
Then
objAcadBlockReference = CType(objAcadEntity,
Interop.Common.AcadBlockReference)
If objAcadBlockReference.Name = "TitleTest" AndAlso
objAcadBlockReference.HasAttributes Then
obj = DirectCast(objAcadBlockReference.GetAttributes,
Object())
For Each objAcadObject In obj
Console.WriteLine("n: " & objAcadObject.ObjectName)
'restult: AcDbAttribute
Console.WriteLine(DirectCast(objAcadObject,
Interop.Common.AcadAttribute).TagString) ' >>> Error: Typs
"System.InvalidCastException"
Next
End If
End If
Next
Next
1 REPLY 1
Message 2 of 2
chiefbraincloud
in reply to: Anonymous

The ARX type AcDbAttribute corresponds to the COM type AcadAttributeReference, not AcadAttribute.
Dave O.                                                                  Sig-Logos32.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost