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

Howto get Space / Layout of object(id)

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
faceter
977 Views, 3 Replies

Howto get Space / Layout of object(id)

Hello,

 

how can I get the Layout of an existing Entity (e.g. AttributeReference entity) ?

 

I have the AttributeReference object and can get it's ObjectID.

Is there a property or function to get the Layout of the object?

 

Thanks a lot for your help

 

nil

3 REPLIES 3
Message 2 of 4
_gile
in reply to: faceter

Hi,

 

You can use the BlockId property of the entity to get ObjectId of the BlockTableRecord instance which owns the entity. It can be either a layout or a block definition.

If you need the Layout instance, you can check if its IsLayout property equals true and, then, get the Layout object with the BlockTableRecord.LayoutId property.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4
faceter
in reply to: _gile

Thanks a lot

works fine.

 

nil

Message 4 of 4
BKSpurgeon
in reply to: _gile

using (Transaction tr = db.TransactionManager.StartTransaction())
{
    Entity entity = tr.GetObject(id, OpenMode.ForRead) as Entity;                    
    BlockTableRecord btr = tr.GetObject(entity.BlockId, OpenMode.ForRead) as BlockTableRecord;

    if (btr.IsLayout)
    {

    }
    else
    {

    }

           

    tr.Commit();
}

 

some code demonstrating the above for a quick cut and paste.

 

All credit to Gilles for the answer.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report