.NET

Reply
Active Member
8 Posts
0 Kudos
Registered: ‎07-21-2006
Post 1 of 16

reading AttributeDefinition

197 Views, 15 Replies
07-21-2006 07:35 AM
hi all,
I have a block that have two attributes( description and amount) the user can fill these in when inserting the block. i can read the Tag and the Prompt, but when i read the textstring it return nothing.
anyone an idea, how do I read the value of the tag.

thanks in advance
*R. Robert Bell
Post 2 of 16

Re: reading AttributeDefinition

07-21-2006 08:56 AM in reply to: pipo2007
Be sure you are getting the AttributeReference objects from the
BlockReference object's GetAttributes method.

--
R. Robert Bell


wrote in message news:5244546@discussion.autodesk.com...
hi all,
I have a block that have two attributes( description and amount) the user
can fill these in when inserting the block. i can read the Tag and the
Prompt, but when i read the textstring it return nothing.
anyone an idea, how do I read the value of the tag.

thanks in advance
*Tony Tanzillo
Post 3 of 16

Re: reading AttributeDefinition

07-21-2006 09:17 AM in reply to: pipo2007
Huh ?

What "GetAttributes" method ????

--
http://www.caddzone.com

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

"R. Robert Bell" wrote in message news:5244711@discussion.autodesk.com...
Be sure you are getting the AttributeReference objects from the
BlockReference object's GetAttributes method.

--
R. Robert Bell


wrote in message news:5244546@discussion.autodesk.com...
hi all,
I have a block that have two attributes( description and amount) the user
can fill these in when inserting the block. i can read the Tag and the
Prompt, but when i read the textstring it return nothing.
anyone an idea, how do I read the value of the tag.

thanks in advance
*Tony Tanzillo
Post 4 of 16

Re: reading AttributeDefinition

07-21-2006 09:22 AM in reply to: pipo2007
You're confusing AttributeDefinition and AttributeReference.

The former appears in the block definition and acts as
a template for creation of the latter, which appears in
each reference/insertion of the block (BlockReference).

You need read the TextString property of the attribute
reference (AttributeReference class). There is one of
these for each attribute, which is accessed via the
AttributeCollection property of the owning BlockReference.

--
http://www.caddzone.com

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

wrote in message news:5244546@discussion.autodesk.com...
hi all,
I have a block that have two attributes( description and amount) the user can fill these in when inserting the block. i can read the Tag and the Prompt, but when i read the textstring it return nothing.
anyone an idea, how do I read the value of the tag.

thanks in advance
*R. Robert Bell
Post 5 of 16

Re: reading AttributeDefinition

07-21-2006 11:18 AM in reply to: pipo2007
Sorry, I missed what group I was in.

--
R. Robert Bell


"Tony Tanzillo" wrote in message
news:5244769@discussion.autodesk.com...
Huh ?

What "GetAttributes" method ????

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
Active Member
8 Posts
0 Kudos
Registered: ‎07-21-2006
Post 6 of 16

Re: reading AttributeDefinition

07-21-2006 11:26 AM in reply to: pipo2007
hi,
so i need to read the attrbuteReference, do you have a sample code VB.net or C#.
now i'm doing this

Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
'CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
'CType(trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead), BlockTableRecord)
Dim id As ObjectId
Dim idnr As Int32

Dim attref As AttributeReference = New AttributeReference()
idnr = 0
For Each id In btr
Dim ent As Entity = trans.GetObject(id, OpenMode.ForRead, False)
'CType(trans.GetObject(id, OpenMode.ForRead, False), Entity)
If TypeOf ent Is BlockReference Then
Dim saEmployeeList(-1) As String

Dim Blk As BlockReference = CType(ent, BlockReference)
Dim br As BlockTableRecord = CType(trans.GetObject(Blk.BlockTableRecord, OpenMode.ForRead, False), BlockTableRecord)
blockname = br.Name
'ListBlocks(id, saEmployeeList, blockname)
Dim sEmployeeData As String
Dim empBtr As BlockTableRecord = trans.GetObject(bt(blockname), OpenMode.ForRead)

ac = Blk.AttributeCollection
Dim entid As ObjectId
For Each entid In empBtr
Dim entt As Entity = trans.GetObject(entid, OpenMode.ForRead, False)
If TypeOf entt Is AttributeDefinition Then
Dim attDef As AttributeDefinition = CType(entt, AttributeDefinition)
attref.SetPropertiesFrom(attDef)
attref.Tag = attDef.Tag


ed.WriteMessage("Block tag = " + attDef.Tag + ControlChars.Lf)
ed.WriteMessage("Tag String = " + " " + attDef.Prompt + ControlChars.Lf)

ed.WriteMessage("Tag String = " + " " + attDef.TextString + ControlChars.Lf)
End If
Next

the above code just give me the Tag and prompt, thanks
Active Member
8 Posts
0 Kudos
Registered: ‎07-21-2006
Post 7 of 16

Re: reading AttributeDefinition

07-21-2006 11:32 AM in reply to: pipo2007
hi,
ops srry it didn't work, if you have any examble pls send them to me

Message was edited by: pipo2007 Message was edited by: pipo2007
*Tony Tanzillo
Post 8 of 16

Re: reading AttributeDefinition

07-24-2006 10:50 AM in reply to: pipo2007
"R. Robert Bell" wrote

>> >> What "GetAttributes" method ????

>> Sorry, I missed what group I was in.

In that case, you have the wrong class names
('BlockReference' and 'AttributeReference'), which
are the proper names of the managed wrapper
classes, but don't exist in ActiveX/VBA.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
Active Member
8 Posts
0 Kudos
Registered: ‎07-21-2006
Post 9 of 16

Re: reading AttributeDefinition

07-25-2006 04:06 AM in reply to: pipo2007
hi Tony,
I get the AttrbuteRefrence of a block, and I get the Tag and value that are constants of the block.
but only two tag's that are must be giving when you insert a block, the description tag and the amount tag, I cant get the value of these tags!!
*Tony Tanzillo
Post 10 of 16

Re: reading AttributeDefinition

07-25-2006 05:19 AM in reply to: pipo2007
You can't expect much help without posting
your code.

--
http://www.caddzone.com

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

wrote in message news:5247127@discussion.autodesk.com...
hi Tony,
I get the AttrbuteRefrence of a block, and I get the Tag and value that are constants of the block.
but only two tag's that are must be giving when you insert a block, the description tag and the amount tag, I cant get the value of these tags!!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post