.NET

.NET

Reply
Valued Contributor
82 Posts
0 Kudos
Registered: ‎11-29-2006
Post 1 of 4

Extract Constant Attributes from Block Reference

235 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
Post 2 of 4

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
Post 3 of 4

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
82 Posts
0 Kudos
Registered: ‎11-29-2006
Post 4 of 4

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
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!