Skip to content

Instantly share code, notes, and snippets.

@Civil3DToolChest
Last active August 29, 2015 13:57
Show Gist options
  • Save Civil3DToolChest/9381959 to your computer and use it in GitHub Desktop.
Save Civil3DToolChest/9381959 to your computer and use it in GitHub Desktop.
basic selection set
[CommandMethod("basicSelSet")]
public void basicSelSet()
{
Document acadDoc = Application.DocumentManager.MdiActiveDocument;
Editor editor = acadDoc.Editor;
PromptSelectionOptions promptSelOpt = new PromptSelectionOptions();
promptSelOpt.MessageForAdding = "Select any objects: ";
PromptSelectionResult result = editor.GetSelection(promptSelOpt);
if (result.Status == PromptStatus.OK)
{
int index = 1;
using (Transaction trans = acadDoc.Database.TransactionManager.StartOpenCloseTransaction())
{
foreach (SelectedObject selObj in result.Value)
{
Entity ent = trans.GetObject(selObj.ObjectId, OpenMode.ForRead) as Entity;
editor.WriteMessage("\nObect " + index.ToString() + " in selection set is type: " + ent.GetRXClass().DxfName);
index++;
}
trans.Commit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment