Hi All,
Bit of a c# newbie so please excuse me if this is an obvious question.
Wrtitng some code where i want to select all blocks in the current paperspace.
I know i can use this code to select all blocks in all paperspace but wondered if there is a way to refine it to do what i want to do?
TypedValue[] filList = new TypedValue[2]
{
new TypedValue(67,1),new TypedValue(0,"INSERT")
};
Solved! Go to Solution.
Solved by _gile. Go to Solution.
You can get the block the selected entity belongs to you using the following :
foreach (ObjectId entId in selectedIds) { Entity ent = (Entity)tr.GetObject(entId, OpenMode.ForRead); BlockTableRecord parentBlk = (BlockTableRecord)tr.GetObject(ent.OwnerId, OpenMode.ForRead); ed.WriteMessage("\n DxfName={0}, EntType={1}, Handle={2}, Layer={3}, Block={4}", entID.ObjectClass.DxfName,ent.GetType().ToString() , ent.Handle.ToString(), ent.Layer.ToString(), parentBlk.Name); }
The block is the modelspace or the Block for the (Current) Layout (layout.BlockTableRecordId)
SENL1367,
Thanks for the reply but not sure i understand.
I have a drawing with 5 drawing sheets (in 5 paperspaces) and i want to select all of the blocks in the paperspace the user is currently viewing.
The (67,1) seems to select from all 5 paperspaces not just the current one.
Thanks again for your help
Mike
Hi,
You can use the layout name in a selection filter with 410 dxf code:
TypedValue[] filList = new TypedValue[2] { new TypedValue(0,"INSERT"), new TypedValue(410, "Layout1") };
If you want to get the current layout name, you can use the CTAB system variable.
string ctab = (string)HostApplicationServices.WorkingDatabase.GetSystemVariable("CTAB"); TypedValue[] filList = new TypedValue[2] { new TypedValue(0,"INSERT"), new TypedValue(410, ctab) };