.NET

Reply
Valued Contributor
LialAtArnold
Posts: 82
Registered: ‎11-29-2006
Message 1 of 4 (217 Views)

Extract Constant Attributes from Block Reference

217 Views, 3 Replies
08-25-2009 09:34 AM
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();
}
}
*James Allen
Message 2 of 4 (217 Views)

Re: Extract Constant Attributes from Block Reference

08-25-2009 07:01 PM 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();
> }
> }
>
*Paul Richardson
Message 3 of 4 (217 Views)

Re: Extract Constant Attributes from Block Reference

08-26-2009 03:11 AM 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();
}
}
Valued Contributor
LialAtArnold
Posts: 82
Registered: ‎11-29-2006
Message 4 of 4 (217 Views)

Re: Extract Constant Attributes from Block Reference

09-09-2009 03:04 PM in reply to: LialAtArnold
James and Paul,

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

Thanks for the help.

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
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

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

Ask the Community