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

Extract Constant Attributes from Block Reference

3 REPLIES 3
Reply
Message 1 of 4
LialAtArnold
410 Views, 3 Replies

Extract Constant Attributes from Block Reference

I am trying to extract the text from the Constant attributes attached to a BlockReference.
I know I have to use a COM object.
The acadBlockRef returns a type System.Object.
How do I get to the attributes inside the AcadBlockReference???

The code is as follows:

foreach (ObjectId aID in dwgDeviceIds)
{
//Create a reference to the block and open it for reading
BlockReference myBR = (BlockReference)tm.GetObject(aID, OpenMode.ForRead);

if (myBR.Layer.Equals("PIDSYM"))
{

AcadBlockReference acadBlockRef = (AcadBlockReference) myBR.AcadObject;

??????? = acadBlockRef.GetConstantAttributes();
}
}
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: LialAtArnold

You may have to use an Object array and then post process if you need it
cast differently.
{code}
Object[] Objs = acadBlockRef.GetConstantAttributes();
AcadAttribute[] Atts = new AcadAttribute[Objs.Length];
Objs.CopyTo(Atts, 0);
{code}

--
James Allen
Malicoat-Winslow Engineers, P.C.
Columbia, MO



lial.williams@arnold.af.mil wrote:
> I am trying to extract the text from the Constant attributes attached to a BlockReference.
> I know I have to use a COM object.
> The acadBlockRef returns a type System.Object.
> How do I get to the attributes inside the AcadBlockReference???
>
> The code is as follows:
>
> foreach (ObjectId aID in dwgDeviceIds)
> {
> //Create a reference to the block and open it for reading
> BlockReference myBR = (BlockReference)tm.GetObject(aID, OpenMode.ForRead);
>
> if (myBR.Layer.Equals("PIDSYM"))
> {
>
> AcadBlockReference acadBlockRef = (AcadBlockReference) myBR.AcadObject;
>
> ??????? = acadBlockRef.GetConstantAttributes();
> }
> }
>
Message 3 of 4
Anonymous
in reply to: LialAtArnold

Object[] objs =
(object[])acadBlockRef.GetConstantAttributes();

wrote in message
news:6242898@discussion.autodesk.com...
I am trying to extract the text from the Constant attributes attached to a
BlockReference.
I know I have to use a COM object.
The acadBlockRef returns a type System.Object.
How do I get to the attributes inside the AcadBlockReference???

The code is as follows:

foreach (ObjectId aID in dwgDeviceIds)
{
//Create a reference to the block and open it for reading
BlockReference myBR = (BlockReference)tm.GetObject(aID,
OpenMode.ForRead);

if (myBR.Layer.Equals("PIDSYM"))
{

AcadBlockReference acadBlockRef = (AcadBlockReference)
myBR.AcadObject;

??????? = acadBlockRef.GetConstantAttributes();
}
}
Message 4 of 4
LialAtArnold
in reply to: LialAtArnold

James and Paul,

Between the two responses I was finally able to get this to work.

Thanks for the help.

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