.NET

Reply
Member
Carlos Cabrera
Posts: 3
Registered: ‎09-14-2005
Message 1 of 6 (91 Views)

Silly question

91 Views, 5 Replies
09-14-2005 03:32 PM
Hello,

I've got a block reference called unitBREF. How do I determine its name? I've seen the other posts on names but for some reason I'm having trouble getting the BlockTableRecord:

BlockReference unitBREF = (BlockReference)ent;
BlockTableRecord blkBTR = ???
string name = blkBTR.name;

Thanks very much for any help!
-Carlos
Member
Carlos Cabrera
Posts: 3
Registered: ‎09-14-2005
Message 2 of 6 (91 Views)

Re: Silly question

09-14-2005 03:33 PM in reply to: Carlos Cabrera
BTW,

I'm using C# with AutoCAD 2006 and VS 2003.

-C
Active Member
brianroth
Posts: 10
Registered: ‎05-31-2005
Message 3 of 6 (91 Views)

Re: Silly question

09-14-2005 03:42 PM in reply to: Carlos Cabrera
Hey Carlos,

Try this (I'm assuming you've already got a transaction object in your routine):

BlockTableRecord blkBTR = (BlockTableRecord)trans.GetObject(unitBREF.BlockTableRecord, OpenMode.ForWrite);
Active Member
brianroth
Posts: 10
Registered: ‎05-31-2005
Message 4 of 6 (91 Views)

Re: Silly question

09-14-2005 03:44 PM in reply to: Carlos Cabrera
Just realized I wrote OpenMode.ForWrite in my reply. That will work, but there's no reason why OpenMode.ForRead wouldn't also work.
Member
Carlos Cabrera
Posts: 3
Registered: ‎09-14-2005
Message 5 of 6 (91 Views)

Re: Silly question

09-14-2005 06:11 PM in reply to: Carlos Cabrera
Hi,

For some reason, "BlockTableRecord" is not listed as a method or member variable of my block reference by Visual Studio. Is it possible that I don't have the correct namespace added? For this reason, I thought I must be doing something wrong.

In spite of this, I made it unitBREF.BlockTableRecord and it works great! Thanks very much for your help.

-Carlos
*Albert Szilvasy
Message 6 of 6 (91 Views)

Re: Silly question

09-16-2005 03:38 PM in reply to: Carlos Cabrera
Try this:
public string GetBlockName(ObjectId idRef)
{
using (Transaction t =
idRef.Database.TransactionManager.StartTransaction())
{
BlockReference bref = (BlockReference)t.GetObject(idRef,
OpenMode.ForRead);
BlockTableRecord btr =
(BlockTableRecord)t.GetObject(bref.BlockId,OpenMode.ForRead);
return btr.Name;
}
}

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

For some reason, "BlockTableRecord" is not listed as a method or member
variable of my block reference by Visual Studio. Is it possible that I
don't have the correct namespace added? For this reason, I thought I must
be doing something wrong.

In spite of this, I made it unitBREF.BlockTableRecord and it works great!
Thanks very much for your help.

-Carlos

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