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
Solved! Go to Solution.
Solved by faceter. Go to Solution.
Solved by _gile. Go to Solution.
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.
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.