<?xml encoding=”UTF-8″>By Augusto Goncalves
When we create a custom command, we want it to integrate with AutoCAD built-in behavior. One of those expected behaviors is the FILEDIA system variable, that indicates if a dialog will show when selecting files.
Many developer make direct use of Autodesk.AutoCAD.Windows.OpenFileDialog class, but this will call directly a dialog. The alternative is PromptSaveFileOptions, that can used with the Editor and has the FILEDIA behavior implemented.
The following code snippet show how to implement it.
<font size="2"><span>Editor</span> ed = <span>Application</span>.DocumentManager.MdiActiveDocument.Editor;<br><span>PromptSaveFileOptions</span> pfso = <span>new</span> <span>PromptSaveFileOptions</span>(<span>"Select a file: "</span>);<br><span>PromptFileNameResult</span> pfnr = ed.GetFileNameForSave(pfso);<br><span>if</span> (pfnr.Status != <span>PromptStatus</span>.OK) <span>return</span>;<br> <br><span>string</span> fileName = pfnr.StringResult;<br><span></span></font>
<font size="2"><span>// do something with the file</span></font>

Leave a Reply