.NET

Reply
Contributor
Posts: 22
Registered: ‎08-25-2012
Message 1 of 3 (115 Views)

Trying to get an attribute list from an object

115 Views, 2 Replies
08-25-2012 12:21 PM

I've looked through many posts and can't make this work. Using ACAD2010. I would appreciate any help.

 

Dim ac AsObject = Nothing

 

If ac IsNothingThen

ac = CreateObject(

"AutoCAD.Application.18") 

Else

ac = GetObject(,

"AutoCAD.Application.18") 

EndIf

 

ac.Documents.Open(SelectedListBox.GetItemText(SelectedListBox.Items(0)))

 

Dim dbxDoc AsObject

dbxDoc = ac.Activedocument

Dim strAttributes As String

Dim varAttributes As Object

Dim entity As Object

 

ForEach entity In dbxDoc.ModelSpace

 

If TypeName(entity) = "AcDbBlockReference" Then

If entity.hasattributes = True Then

varAttributes = entity.GetAttributes

strAttributes =""

For i = LBound(varAttributes) ToUBound(varAttributes)

MsgBox("BLOCKNAME: "& entity.name & vbCr _

&

"TAG : "& varAttributes(i).TagString & vbCr _

&

"VALUE : "& varAttributes(i).TextString)

 

Next

EndIf

EndIf

Next entity

*Expert Elite*
Alfred.NESWADBA
Posts: 8,523
Registered: ‎06-29-2007
Message 2 of 3 (109 Views)

Re: Trying to get an attribute list from an object

08-25-2012 01:33 PM in reply to: phives

Hi,

 

and where is the problem? (what line of code and what exception do you get)

I have'nt tried your code, but as long as I don't see where your problem is I also would not spent to much time in getting it into a sample-project to try it. Just looking to your code for few seconds I don't see a problem .... well except of that I would run with Option Strict ON so I couldn't do any type mismatches.

 

Additionally a drawing may help, that you use for testing. But as long as you have blockreferences with attributereferences in it .... ???

 

- alfred -

 

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
Posts: 22
Registered: ‎08-25-2012
Message 3 of 3 (108 Views)

Re: Trying to get an attribute list from an object

08-25-2012 01:37 PM in reply to: Alfred.NESWADBA

Tx. I figured it out just before your answer.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community