.NET

Reply
Active Contributor
jamierobertson1
Posts: 39
Registered: ‎04-11-2004
Message 1 of 7 (379 Views)
Accepted Solution

stopping palette being restored on startup

379 Views, 6 Replies
05-22-2012 12:51 PM

Is there anyway to stop AutoCAD executing the command used to create a palette upon AutoCAD startup?

 

I know constructing the palette without a GUID prevents this behaviour but I'd like keep this to preserve the palette size, position, state etc given when a GUID is provided.

 

I had hoped I could just close / make not visible  the palette just before AutoCAD exits and it wouldn't try and restore the palette upon the next AutoCAD started. I've tried doing this in the Application.BeginQuit event but the command is still called the next time AutoCAD is started.

 

Any ideas?

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 2 of 7 (341 Views)

Re: stopping palette being restored on startup

05-24-2012 11:04 PM in reply to: jamierobertson1
Hi, I'm a bit confused what you are asking. Are you talking about an AutoCAD palette or your own custom .NET palette? If you are talking about your own custom .NET palette, how is AutoCAD executing your command to create the palette on startup? Did you add it to a lisp file, are you doing this in the IApplicationExtension.Initialize() method, or using the autoloader mechanism? Art
Active Contributor
jamierobertson1
Posts: 39
Registered: ‎04-11-2004
Message 3 of 7 (332 Views)

Re: stopping palette being restored on startup

05-25-2012 01:37 AM in reply to: Artvegas

It's a custom control hosted in an AutoCAD Palleteset. It is executed by a custom CommandMethod in an assembly thats auto-loaded from a registry key.

 

The problem is that everytime AutoCAD starts the commandMethod command is automatically called (you can see it in the commandline) if the palleteSet was visible when AutoCAD was last closed. As I  understand it AutoCAD tries to restore the state of Palettes from the last session everytime it's started. If I manually close the Palettset before closing AutoCAD then AutoCAD doesnt execute the command the next time AutoCAD starts(what I want, but I cant seem to do this programatically).

 

I'd like the Palletset to never be restored by AutoCAD on startup. It's quite a big pallette and seems to cause confusion to some people if it pops up when AutoCAD starts..

 

It's not really a big deal really though and I can see the logic behind why AutoCAD does this, I  just wondered if anyone had managed to (or wanted to) circumvent it before.

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 4 of 7 (322 Views)

Re: stopping palette being restored on startup

05-25-2012 04:29 AM in reply to: jamierobertson1

I get you. I think I know how to fix this. It's how you specify the first parameter of the PaletteSet constructor. The ObjectARX documentation for this is not clear. For example:

 

   PaletteSet ps
      = new PaletteSet(
            "MYPALETTESET",
            new Guid("A2E356FA-1C86-410E-BEBC-79CC4515925E"
         ));

 

The "MYPALETTESET" name parameter is NOT the name of the PaletteSet, rather it's the name of the command that AutoCAD will issue to show the PaletteSet when AutoCAD re-starts (i.e. if it was visible when you quit).

 

If your the palette was visible the last time you exited AutoCAD and your command to show the palette is also "MYPALETTESET", AutoCAD will call this command on startup (hence making your palette visible).

 

So the solution to your problem is pretty simple. Instead specify an empty string for the name parameter, i.e.:

 

   PaletteSet ps
      = new PaletteSet(
            "",
            new Guid("A2E356FA-1C86-410E-BEBC-79CC4515925E"
         ));

 

This should do the trick.

 

As a side note I discovered that the palette data is stored in the Profile.aws file (actually an xml file) located here:

C:\Users\<UserName>\AppData\Roaming\Autodesk\AutoCAD XXXX\RXX.X\enu\Support\Profiles\Unnamed Profile\Profiles.awt

 

Anyways let me know if this fixed it for you.

 

Art.

 

p.s. Kudos to Tony Tanzillo for the solution:
http://forums.autodesk.com/t5/NET/PaletteSet-Title-Command-GUID-Confusion/td-p/2661021

Active Contributor
jamierobertson1
Posts: 39
Registered: ‎04-11-2004
Message 5 of 7 (316 Views)

Re: stopping palette being restored on startup

05-25-2012 04:42 AM in reply to: Artvegas

That fixed it perfectly, thanks very much!

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 6 of 7 (311 Views)

Re: stopping palette being restored on startup

05-25-2012 05:34 AM in reply to: jamierobertson1

You're most welcome.

 

Just one other thing to clarify. The constructor's name parameter actually sets both the name of the command for restart AND the title text for the palette window. So you might notice that the title of your palette is empty. If you want to set the title do the following:

 

   PaletteSet ps
      = new PaletteSet("", new Guid("A2E356FA-1C86-410E-BEBC-79CC4515925E"));
   ps.Name = "Title of My Palette";

 

It seems the constructor's name parameter sets both the command for restart and the title text. But if you set the Name property again it only changes the title text.

 

Seems like these really should have different properties (i.e. RestartCommandName and Title), but that's how it is sometimes :-)

 

Art

Member
Brad_Hamilton
Posts: 5
Registered: ‎03-15-2010
Message 7 of 7 (206 Views)

Re: stopping palette being restored on startup

11-28-2012 10:41 AM in reply to: Artvegas

Not sure if true when the post was originated, but there is another overload which specifically addresses the command:

namespace Autodesk.AutoCAD.Windows

{

[Wrapper("AdUiPaletteSet")]

public class PaletteSet : Window, ICollection

{

public PaletteSet(string name);

public PaletteSet(string name, Guid toolID);

public PaletteSet(string name, string cmd, Guid toolID);

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.