Code Red > .NET
Need help with a window command in C#
(1/1)
Nomad:
I have created a plugin written in C# that runs in Autocad. The plugin opens a window and allows the user to select several options to restore default settings for the sheet. When I run a command that requires additional user input beyond the button on the window, a blank white box pops up called "Hidden Window" and disappears after the command runs. How do I stop this from happening. Any help would be greatly appreciated.
This is the initialization command for the window.
--- Code - C#: ---public class Initialize { [CommandMethod("Defaults")] public static void window() { GUI window = new GUI(); //initializes window window.ShowDialog(); } }
This is the command for the additional user input.
--- Code - C#: ---public static void UpdateLayer() { Document acDoc = Application.DocumentManager.MdiActiveDocument; //AutoCAD document name in program space Database acCurDb = acDoc.Database; //AutoCAD database name in program space Editor ed = acDoc.Editor; //AutoCAD document editor PromptDistanceOptions prompt = new PromptDistanceOptions(""); prompt.Message = "\nWould you like to add missing layers?"; prompt.Keywords.Add("Yes"); prompt.Keywords.Add("No"); PromptDoubleResult result = acDoc.Editor.GetDistance(prompt); //Updates the missing engineering layers in the autocad drawing if (result.StringResult == "Yes") { Globals.NoCreate(1); } //runs the first command so the description can correctly update else if (result.StringResult == "No") { Globals.NoCreate(0); } EngineeringLayersDatabase.UpdateLayer(); }
edit kdub: added code=csharp
kdub_nz:
Hi Nomad
I can't visualise the issue you have.
I'm wondering why you are using the Editor.GetDistance() method ??
Perhaps Editor.GetKeyword() would be more suitable.
. . or code a YesNo MessageBox for yourself
Something like : https://www.c-sharpcorner.com/UploadFile/mahesh/understanding-message-box-in-windows-forms-using-C-Sharp/
or :
https://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-6C52F8BC-B107-4EE4-BA25-5B74900B271A
https://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-F432E285-8B94-4ACD-A186-89E1218DEC07
It's Alive!:
Hi,
Did you try using Application.ShowModalDialog?
AutoCAD keeps a reference to the window as to hook into its events
kdub_nz:
--- Quote from: It's Alive! on July 08, 2022, 08:08:40 AM ---Hi,
Did you try using Application.ShowModalDialog?
AutoCAD keeps a reference to the window as to hook into its events
--- End quote ---
Hi Daniel,
I s'pose it also depends if the Button_Click event closes the Form prior to calling UpdateLayer()
Navigation
[0] Message Index
Go to full version