-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ Thumbs.db | |
*.ide-wal | ||
*.dll | ||
*.suo | ||
*.dwl | ||
*.dwl2 | ||
[Bb]in | ||
[Dd]ebug*/ | ||
*.lib | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using Autodesk.AutoCAD.ApplicationServices.Core; | ||
using Autodesk.AutoCAD.DatabaseServices; | ||
using Autodesk.AutoCAD.EditorInput; | ||
using Autodesk.AutoCAD.Runtime; | ||
|
||
namespace Test; | ||
|
||
public class MergeSelection | ||
{ | ||
[CommandMethod("MergeSelectionSets")] | ||
public static void MergeSelectionSets() | ||
{ | ||
// Get the current document editor | ||
Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor; | ||
// Request for objects to be selected in the drawing area | ||
|
||
PromptSelectionResult acSSPrompt; | ||
|
||
acSSPrompt = acDocEd.GetSelection(); | ||
SelectionSet acSSet1; | ||
|
||
ObjectIdCollection acObjIdColl = new ObjectIdCollection(); | ||
// If the prompt status is OK, objects were selected | ||
|
||
if (acSSPrompt.Status == PromptStatus.OK) | ||
|
||
{ | ||
// Get the selected objects | ||
|
||
acSSet1 = acSSPrompt.Value; | ||
// Append the selected objects to the ObjectIdCollection | ||
|
||
acObjIdColl = new ObjectIdCollection(acSSet1.GetObjectIds()); | ||
} | ||
// Request for objects to be selected in the drawing area | ||
|
||
acSSPrompt = acDocEd.GetSelection(); | ||
SelectionSet acSSet2; | ||
|
||
|
||
// If the prompt status is OK, objects were selected | ||
|
||
if (acSSPrompt.Status == PromptStatus.OK) | ||
|
||
{ | ||
acSSet2 = acSSPrompt.Value; | ||
|
||
|
||
// Check the size of the ObjectIdCollection, if zero, then initialize it | ||
|
||
if (acObjIdColl.Count == 0) | ||
|
||
{ | ||
acObjIdColl = new ObjectIdCollection(acSSet2.GetObjectIds()); | ||
} | ||
|
||
else | ||
|
||
{ | ||
// Step through the second selection set | ||
|
||
foreach (ObjectId acObjId in acSSet2.GetObjectIds()) | ||
|
||
{ | ||
// Add each object id to the ObjectIdCollection | ||
|
||
acObjIdColl.Add(acObjId); | ||
} | ||
} | ||
} | ||
|
||
|
||
Application.ShowAlertDialog("Number of objects selected: " + | ||
acObjIdColl.Count.ToString()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Autodesk.AutoCAD.ApplicationServices.Core; | ||
using Autodesk.AutoCAD.DatabaseServices; | ||
using Autodesk.AutoCAD.EditorInput; | ||
using Autodesk.AutoCAD.Runtime; | ||
|
||
namespace Test; | ||
|
||
public class MultiFilterRule | ||
{ | ||
[CommandMethod("FilterBlueCircleOnLayer0")] | ||
public static void FilterBlueCircleOnLayer0() | ||
|
||
{ | ||
// Get the current document editor | ||
|
||
Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor; | ||
// Create a TypedValue array to define the filter criteria | ||
|
||
TypedValue[] acTypValAr = new TypedValue[3]; | ||
|
||
acTypValAr.SetValue(new TypedValue((int) DxfCode.Color, 5), 0); | ||
|
||
acTypValAr.SetValue(new TypedValue((int) DxfCode.Start, "CIRCLE"), 1); | ||
|
||
acTypValAr.SetValue(new TypedValue((int) DxfCode.LayerName, "Layer2"), 2); | ||
|
||
|
||
// Assign the filter criteria to a SelectionFilter object | ||
SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); | ||
// Request for objects to be selected in the drawing area | ||
|
||
PromptSelectionResult acSSPrompt; | ||
|
||
acSSPrompt = acDocEd.GetSelection(acSelFtr); | ||
// If the prompt status is OK, objects were selected | ||
|
||
if (acSSPrompt.Status == PromptStatus.OK) | ||
{ | ||
SelectionSet acSSet = acSSPrompt.Value; | ||
Application.ShowAlertDialog("Number of objects selected: " + | ||
acSSet.Count.ToString()); | ||
} | ||
|
||
else | ||
|
||
{ | ||
Application.ShowAlertDialog("Number of objects selected: 0"); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Autodesk.AutoCAD.ApplicationServices.Core; | ||
using Autodesk.AutoCAD.DatabaseServices; | ||
using Autodesk.AutoCAD.EditorInput; | ||
using Autodesk.AutoCAD.Runtime; | ||
|
||
namespace Test; | ||
|
||
public class SelectionFilters | ||
{ | ||
[CommandMethod("FilterSelectionSet")] | ||
public static void FilterSelectionSet() | ||
|
||
{ | ||
// Get the current document editor | ||
|
||
Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor; | ||
// Create a TypedValue array to define the filter criteria | ||
|
||
TypedValue[] acTypValAr = new TypedValue[1]; | ||
|
||
acTypValAr.SetValue(new TypedValue((int) DxfCode.Start, "CIRCLE"), 0); | ||
// Assign the filter criteria to a SelectionFilter object | ||
|
||
SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); | ||
// Request for objects to be selected in the drawing area | ||
|
||
PromptSelectionResult acSSPrompt; | ||
|
||
acSSPrompt = acDocEd.GetSelection(acSelFtr); | ||
|
||
|
||
// If the prompt status is OK, objects were selected | ||
|
||
if (acSSPrompt.Status == PromptStatus.OK) | ||
|
||
{ | ||
SelectionSet acSSet = acSSPrompt.Value; | ||
|
||
Application.ShowAlertDialog("Number of objects selected: " + acSSet.Count.ToString()); | ||
} | ||
else | ||
{ | ||
Application.ShowAlertDialog("Number of objects selected: 0"); | ||
} | ||
} | ||
} |