Message 1 of 2

Not applicable
08-17-2018
09:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to find all the blocks, lines, circles etc. on a layer. I have found two possible way of doing this but I am having problems with them both. My first method was from here where I used something like:
public static void LayerInfoGrab(string LayerName, int LayerType) { //link to the current document and databases Document Doc = Application.DocumentManager.MdiActiveDocument; Database db = Doc.Database; Editor ed = Doc.Editor; using (Transaction Trans = db.TransactionManager.StartTransaction()) { //Open the block table open for read BlockTable Btr = Trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; //Open the model space database for read BlockTableRecord BtrModel = Trans.GetObject(Btr[BlockTableRecord.ModelSpace],OpenMode.ForRead) as BlockTableRecord; //Step through the objects and find any on the layer we want foreach (object SPAobject in BtrModel) { //Test the object for block type if (SPAobject is Line) { } if (SPAobject is Circle)
But (SPAobject is Block) does not work. My second method is the selection filter but I don't have a name for the block, but I do want all the blocks on the layer. I didn't know if I could use something like "*" instead of the block name?
Solved! Go to Solution.