Select blocks in current paperspace

Select blocks in current paperspace

miketurpin_innovatingfutures
Enthusiast Enthusiast
1,341 Views
4 Replies
Message 1 of 5

Select blocks in current paperspace

miketurpin_innovatingfutures
Enthusiast
Enthusiast

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")

};

 

0 Likes
Accepted solutions (1)
1,342 Views
4 Replies
Replies (4)
Message 2 of 5

SENL1362
Advisor
Advisor
there is only one (currrent) Paperspace, so 67==1 select block REFERENCES for the active Layout only.
0 Likes
Message 3 of 5

SENL1362
Advisor
Advisor

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)

 

 

0 Likes
Message 4 of 5

miketurpin_innovatingfutures
Enthusiast
Enthusiast

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

0 Likes
Message 5 of 5

_gile
Consultant
Consultant
Accepted solution

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)
};

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub