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

Silly question

5 REPLIES 5
Reply
Message 1 of 6
Carlos Cabrera
253 Views, 5 Replies

Silly question

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
5 REPLIES 5
Message 2 of 6

BTW,

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

-C
Message 3 of 6
brianroth
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);
Message 4 of 6
brianroth
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.
Message 5 of 6

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
Message 6 of 6
Anonymous
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

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