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

PaletteSet and Editor problem

2 REPLIES 2
Reply
Message 1 of 3
markodjurovic
329 Views, 2 Replies

PaletteSet and Editor problem

I have some problems with PaletteSet object and Editor:
I have one static member variable:

static Autodesk.AutoCAD.Windows.PaletteSet ps;

and on some command I set it to visible and that looks like this:

[CommandMethod("TCG", "TRASA", CommandFlags.Modal)]
public static void InsertTrasa()
{
if (Key.CheckLicence() == false)
{
int count = AcadUtilities.GetEntityCount();
if (count >= Key.MAX_OBJECTS)
{
DialogBox dlg = new DialogBox(DialogMode.NotLicensed);
dlg.TopMost = true;
dlg.ShowDialog();
return;
}
}

if (routeEditorAdded == false)
{
PaletteSet ps = new Autodesk.AutoCAD.Windows.PaletteSet("Osobine segmenta trase", new Guid("{B28F5CF7-AC01-4348-9726-FA02D1A75305}"));

ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.NameEditable |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton;

re = new RouteEditor();

routeEditorAdded = true;

re.SizeChanged += new EventHandler(re_SizeChanged);
ps.Add("Segment", re);
ps.Size = new System.Drawing.Size(400, 600);
ps.Location = new System.Drawing.Point(100, 100);
ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Right;
}
ps.Visible = true;

After that I am calling editor method to pick some point:

PromptPointResult ppr = Application.DocumentManager.MdiActiveDocument.Editor.GetPoint("Select point");

and WTF!!!! Editor somehow detects that operation GetPoint is canceled and ppr.Status is equal to PromptStatus.Cancel. Please, if someone have solution for this problem, help. Note: nothing of this happening if comment line ps.Visible = true (when ps stays unvisible editor works fine)
2 REPLIES 2
Message 2 of 3

correction I didn't copy/pasted good

static PaletteSet ps; // staic member
.
.
.//in command I have like this:

if (routeEditorAdded == false)
{
ps = new Autodesk.AutoCAD.Windows.PaletteSet("Osobine segmenta trase", new Guid("{B28F5CF7-AC01-4348-9726-FA02D1A75305}"));
ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.NameEditable |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton |
Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton;

re = new RouteEditor();

routeEditorAdded = true;

re.SizeChanged += new EventHandler(re_SizeChanged);
ps.Add("Segment", re);
ps.Size = new System.Drawing.Size(400, 600);
ps.Location = new System.Drawing.Point(100, 100);
ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Right;
}
ps.Visible = true;

//And after that I call:
PromptPointResult ppr = Application.DocumentManager.MdiActiveDocument.Editor.GetPoint("Select point");

And automaticly I get that the GetPoint is Canceled and status is PromptStatus.Cancel. Whe ps stays unvisible everything is fine
Message 3 of 3
FRFR1426
in reply to: markodjurovic

I'm a bit late, but I add this for reference. The problem is that when you change the property Visible on the palette set (ps.Visible = true), AutoCAD execute the command associated to the palette set to show or hide it. The workaround is to stop the command and restart it when the palette is visible:

 

if (!ps.Visible)
{
  ps.Visible = true;
  ed.EnteringQuiescentState += ed_EnteringQuiescentState;
  return;
}

[..]

void ed_EnteringQuiescentState(object sender, EventArgs e)
{
    var ed = (Editor) sender;
    try
    {
        ed.Document.SendStringToExecute(CMD + "\n", false, false, false);
    }
    finally
    {
        ed.EnteringQuiescentState -= ed_EnteringQuiescentState;
    }
}

 

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr

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