.NET

.NET

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

Extract Constant Attributes from Block Reference

234 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 (234 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 (234 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 (234 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.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.