This documentation covers the standard system dialogs provided by the Autodesk.AutoCAD.Windows namespace, allowing developers to invoke native AutoCAD pickers for files, colors, and linetypes.
Autodesk.AutoCAD.Windows
| Class | Description |
|---|---|
OpenFileDialog |
Standard file open dialog. |
SaveFileDialog |
Standard file save dialog. |
ColorDialog |
AutoCAD Color Index (ACI) and TrueColor picker. |
LinetypeDialog |
Linetype selection dialog. |
LayerDialog |
Layer selection dialog (via internal UI or custom). |
using Autodesk.AutoCAD.Windows;
OpenFileDialog ofd = new OpenFileDialog(
"Select Configuration",
null,
"xml;json",
"SettingsFiles",
OpenFileDialog.OpenFileDialogFlags.DoNotTransferRemoteFiles
);
System.Windows.Forms.DialogResult dr = ofd.ShowDialog();
if (dr == System.Windows.Forms.DialogResult.OK)
{
string selectedFile = ofd.Filename;
// Process file
}SaveFileDialog sfd = new SaveFileDialog(
"Export Data",
"report",
"csv",
"ExportFile",
SaveFileDialog.SaveFileDialogFlags.None
);
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string savePath = sfd.Filename;
}ColorDialog cd = new ColorDialog();
cd.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 1); // Default Red
cd.IncludeByBlockByLayer = true; // Allow ByLayer/ByBlock
if (cd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Autodesk.AutoCAD.Colors.Color selected = cd.Color;
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\nSelected: {selected.ColorIndex}");
}LinetypeDialog ltd = new LinetypeDialog();
// ltd.LinetypeId = ...; // Set default
if (ltd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ObjectId linetypeId = ltd.LinetypeId;
// Apply linetype
}// AutoCAD provides standard MessageBox integration but usually you use standard Forms/WPF
// For AutoCAD-style alert:
Application.ShowAlertDialog("Critical Error Occurred!");// There is no simplistic "LayerDialog" class exposed directly like ColorDialog.
// Usually developers build a custom form listing layers from the database,
// or use COM interop to invoke built-in dialogs.// Dialogs return System.Windows.Forms.DialogResult
// Remember to reference System.Windows.Forms
if (result == System.Windows.Forms.DialogResult.Cancel)
{
// User cancelled
return;
}// For folder selection, use standard .NET
// System.Windows.Forms.FolderBrowserDialog
// AutoCAD does not provide a specific override for this.- Modal Context: These dialogs are modal. They block the AutoCAD UI until closed.
- References: Requires
System.Windows.Formsreference in your project. - UI Thread: Always show dialogs from the main UI thread.