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

Select blocks in current paperspace

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
miketurpin_innovatingfutures
560 Views, 4 Replies

Select blocks in current paperspace

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

};

 

4 REPLIES 4
Message 2 of 5

there is only one (currrent) Paperspace, so 67==1 select block REFERENCES for the active Layout only.
Message 3 of 5
SENL1362
in reply to: SENL1362

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)

 

 

Message 4 of 5

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

Message 5 of 5

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

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