.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting User Input error after showing a paletteset

4 REPLIES 4
Reply
Message 1 of 5
cincir
571 Views, 4 Replies

Getting User Input error after showing a paletteset

Hello everyone,

I have got a problem about getting user input.

In a function i am first getting a selection from the user by editor.getselection(...)

then i show a paletteset with my usercontrol in the same function. everything is fine so far.

but after showing paletteset i try to get a string from the user by editor.getstring(...) in the same function but statement continues as i never request it. when i check the PromptResult status it is equal to cancel.

i mean

            Transaction acTrans = null;

            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            acDocLock = acDoc.LockDocument();
            using (acDocLock)
            {
                PromptSelectionOptions acOPrompt = new PromptSelectionOptions();
                acOPrompt.MessageForAdding = "Select objects";
                PromptSelectionResult acSPrompt = acDoc.Editor.GetSelection(acOPrompt);

                if (acSPrompt.Status == PromptStatus.OK)
                {
                    acTrans = acCurDb.TransactionManager.StartTransaction();
                    try
                    {
                        // Process selected objects

                            ShowPalette(true);

                            PromptStringOptions pso = new PromptStringOptions("Enter name for selection");
                            pso.AllowSpaces = true;

                            PromptResult pr;

                            do
                            {
                                pr = acDoc.Editor.GetString(pso); //--------->never stop there if showpalette is executed.
                            } while (pr.Status == PromptStatus.OK);

i tried to lock the document but it doesnt work either. when i comment out "showpalette(true)" it works correctly.
i realized that if my document window s state is not WindowState.Maximized then my code works just fine but if it is WindowState.Maximized it does not work. it may be a clue.
can anyone help me about this problem.

thanks in advance.

4 REPLIES 4
Message 2 of 5
Artvegas
in reply to: cincir

Yes I see what you mean. Strange behaviour indeed.

 

I found a work-around though. If you place the code that you want to execute after showing the palette in a seperate command and send it to the command-line, it seems to work, i.e. as follows:

 

[CommandMethod("ShowPaletteCommand")]
public static void ShowPaletteCommand() {

      Document doc = Application.DocumentManager.MdiActiveDocument;

      PromptSelectionOptions acOPrompt = new PromptSelectionOptions();
      acOPrompt.MessageForAdding = "Select objects";
     
PromptSelectionResult acSPrompt = doc.Editor.GetSelection(acOPrompt);

      // Prompt for strings BEFORE showing palette.
     
doc.SendStringToExecute("PromptForStrings ", false, false, false);
      ShowPalette(true);
}

 

// Note: CommandFlags.NoUndoMarker set so that that the user won't have to undo
//           twice if they wanted to undo the SHOWPALETTECOMMAND.
[CommandMethod("PromptForStrings", CommandFlags.NoUndoMarker) {
public static void PromptForStrings() {

      Document doc = Application.DocumentManager.MdiActiveDocument;

      PromptStringOptions pso = new PromptStringOptions("Enter name for selection");
      pso.AllowSpaces = true;
      PromptResult pr;
      do {
         pr = doc.Editor.GetString(pso);
      } while (pr.Status == PromptStatus.OK);
}

 

Not sure if this will work in your situation, but hope this helps.

 

Art

Message 3 of 5
jeff
in reply to: Artvegas

Have you tried placing this before you prompt for the string

Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView()

You can also find your answers @ TheSwamp
Message 4 of 5
Artvegas
in reply to: jeff

Hi Jeff,

 

Thank you for the suggestion.

 

I tried the Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView() method both before and after setting the PaletteSet to be visible, but the highlighted problem still occurs.

 

It appears that AutoCAD has an internal implementation that cancels any active commands before opening a PaletteSet for display. If the PaletteSet is already visible there is no problem.

 

If you start a command and then transparently open any palette this will occur. For example if you start the CIRCLE command and then transparently open the layer palette (i.e. 'LAYER), you will see the CIRCLE command is cancelled.

 

I think the reason that the approach I suggested works is because the SendStringToExecute() is executed asynchronously - i.e. after the palette has been made visible and cancel has been sent to the command-line.

 

As highlighted by 'cincir' in his initial post, what makes this behaviour strange is that if the current dwg document's window state is NOT maximised, then the problem doesn't appear. It only happens when the window state IS maximized. This also applies to the CIRCLE command and layer palette example I gave above - i.e. it's not .NET specific.

 

I'm quite surprised no-one at Autodesk has picked this up. I would think it would be quite common for someone to want to display a palette and then prompt the user to interact within the editor window, such as to provide dynamic visual feedback to the user as items are selected or modified.

 

Art

Message 5 of 5
cincir
in reply to: cincir

It is a bit late but thank you Artvegas. in my situation sendstringtoexecute will not solve my problem. but thanks for your affords. as you mentioned it is common to show a palette in a command and continue the command. it will be good if someone from autodesk shows us a way or fix this in later versions.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost