AttributeReference TextString problem

AttributeReference TextString problem

Anonymous
Not applicable
538 Views
4 Replies
Message 1 of 5

AttributeReference TextString problem

Anonymous
Not applicable
Hi,

I need to obtain the value of an AttributeReference in a BlockReference, I've done everything necessary to obtain the AttributeReference without problem, but when I access the TextString property it returns "" (Empty), I know for sure the drawing has value assigned in the block.

Any help is appreciated, thanks

Eric
0 Likes
539 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
There's not much anyone can do without seeing your code.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5944798@discussion.autodesk.com...
Hi,

I need to obtain the value of an AttributeReference in a BlockReference, I've done everything necessary to obtain the AttributeReference without problem, but when I access the TextString property it returns "" (Empty), I know for sure the drawing has value assigned in the block.

Any help is appreciated, thanks

Eric
0 Likes
Message 3 of 5

Anonymous
Not applicable
Hi,

I don't know why but with some new drawings, done with full AutoCAD, I can successfully read the attributes values, but with other drawings which have been modified and saved with AutoCAD LT I can't.

Thanks,

Eric
0 Likes
Message 4 of 5

Anonymous
Not applicable
Got a sample?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5947497@discussion.autodesk.com...
Hi,

I don't know why but with some new drawings, done with full AutoCAD, I can successfully read the attributes values, but with other drawings which have been modified and saved with AutoCAD LT I can't.

Thanks,

Eric
0 Likes
Message 5 of 5

Anonymous
Not applicable
Hi Tony,

This is the code I'm using:

[CommandMethod("tar")]
public void TestAttributeReference()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt["INFO_HOJAS_ATT"], OpenMode.ForRead);
foreach (ObjectId oid in btr.GetBlockReferenceIds(true, false))
{
BlockReference titleBlock = trans.GetObject(oid, OpenMode.ForRead) as BlockReference;
if (titleBlock == null) continue;
foreach (ObjectId attOid in titleBlock.AttributeCollection) {
AttributeReference ar = (AttributeReference)trans.GetObject(attOid, OpenMode.ForWrite);
ed.WriteMessage(String.Format("{0} = {1}\n", ar.Tag, ar.TextString));
// ...
}
}
// trans.Commit();
}
}

And attached id one of the files without xrefs. But now is working fine I'm using a different PC from the original test. Will check tomorrow from the office.

Thanks,
Eric
0 Likes