Created
March 6, 2014 04:43
-
-
Save Civil3DToolChest/9382815 to your computer and use it in GitHub Desktop.
select blocks only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CommandMethod("selectBlocksOnly")] | |
public void selectBlocksOnly() | |
{ | |
Document acadDoc = Application.DocumentManager.MdiActiveDocument; | |
Editor editor = acadDoc.Editor; | |
PromptSelectionOptions promptSelOpt = new PromptSelectionOptions(); | |
promptSelOpt.MessageForAdding = "Select block objects: "; | |
TypedValue[] tVs = new TypedValue[] { new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(BlockReference)).DxfName) }; | |
SelectionFilter filter = new SelectionFilter(tVs); | |
PromptSelectionResult result = editor.GetSelection(promptSelOpt, filter); | |
int index = 1; | |
if (result.Status == PromptStatus.OK) | |
{ | |
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction()) | |
{ | |
foreach (SelectedObject selObj in result.Value) | |
{ | |
BlockReference blockRef = trans.GetObject(selObj.ObjectId, OpenMode.ForRead) as BlockReference; | |
editor.WriteMessage("\nObject " + index.ToString() + " in selection set is type: " + blockRef.GetRXClass().DxfName + " Named: " + blockRef.Name); | |
index++; | |
} | |
trans.Commit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment