You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Editor class provides methods for user interaction, command-line input/output, and entity selection in AutoCAD.
Namespace
Autodesk.AutoCAD.EditorInput
Inheritance Hierarchy
System.Object
└─ Editor
Key Methods - Output
Method
Return Type
Description
WriteMessage(string)
void
Writes message to command line
WriteMessage(string, params object[])
void
Writes formatted message
Key Methods - Input
Method
Return Type
Description
GetString(string)
PromptResult
Prompts for string input
GetInteger(string)
PromptIntegerResult
Prompts for integer
GetDouble(string)
PromptDoubleResult
Prompts for double
GetPoint(string)
PromptPointResult
Prompts for point
GetDistance(string)
PromptDoubleResult
Prompts for distance
GetAngle(string)
PromptDoubleResult
Prompts for angle
GetKeywords(string, params string[])
PromptResult
Prompts for keyword
Key Methods - Selection
Method
Return Type
Description
GetSelection()
PromptSelectionResult
Prompts for entity selection
GetSelection(SelectionFilter)
PromptSelectionResult
Selection with filter
SelectAll(SelectionFilter)
PromptSelectionResult
Selects all entities
Code Examples
Example 1: Writing to Command Line
usingAutodesk.AutoCAD.ApplicationServices;usingAutodesk.AutoCAD.EditorInput;DocumentacDoc=Application.DocumentManager.MdiActiveDocument;Editored=acDoc.Editor;ed.WriteMessage("\nHello from AutoCAD!");ed.WriteMessage("\nFormatted: {0}, {1}",123,"test");
Example 2: Getting User Input
usingAutodesk.AutoCAD.EditorInput;Editored=Application.DocumentManager.MdiActiveDocument.Editor;// Get stringPromptStringOptionspso=newPromptStringOptions("\nEnter your name: ");PromptResultpr=ed.GetString(pso);if(pr.Status==PromptStatus.OK){stringname=pr.StringResult;ed.WriteMessage($"\nHello, {name}!");}// Get integerPromptIntegerOptionspio=newPromptIntegerOptions("\nEnter a number: ");pio.AllowNegative=false;PromptIntegerResultpir=ed.GetInteger(pio);if(pir.Status==PromptStatus.OK){intnumber=pir.Value;}// Get pointPromptPointOptionsppo=newPromptPointOptions("\nSelect a point: ");PromptPointResultppr=ed.GetPoint(ppo);if(ppr.Status==PromptStatus.OK){Point3dpoint=ppr.Value;}
Example 3: Entity Selection
usingAutodesk.AutoCAD.EditorInput;Editored=Application.DocumentManager.MdiActiveDocument.Editor;PromptSelectionResultselResult=ed.GetSelection();if(selResult.Status==PromptStatus.OK){SelectionSetselSet=selResult.Value;ed.WriteMessage($"\n{selSet.Count} objects selected");ObjectId[]ids=selSet.GetObjectIds();// Work with selected objects}
Example 4: Filtered Selection
usingAutodesk.AutoCAD.EditorInput;Editored=Application.DocumentManager.MdiActiveDocument.Editor;// Create filter for lines onlyTypedValue[]filterList=newTypedValue[]{newTypedValue((int)DxfCode.Start,"LINE")};SelectionFilterfilter=newSelectionFilter(filterList);PromptSelectionResultselResult=ed.GetSelection(filter);if(selResult.Status==PromptStatus.OK){ed.WriteMessage($"\n{selResult.Value.Count} lines selected");}