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

Cutom palette save load position

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
andre_adc-dao
940 Views, 6 Replies

Cutom palette save load position

Hello,

 

I've creating a custom palette with VB .Net. It is working well. Now I would like to save and load last position  (dock or float). I created my palette base on this document http://forums.autodesk.com/autodesk/attachments/autodesk/152/26712/1/CP205-2_Mike_Tuersley.pdf. In this document there is a section «Restoring user settings». So I follow these instructions:

 

Add: Implements Autodesk.AutoCAD.Runtime.IExtensionApplication at the beginning of the class

 

Add these functions:

 

Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize

    End Sub

    Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate

    End Sub
    Private Shared Sub ps_Load(ByVal sender As Object, _
                               ByVal e As Autodesk.AutoCAD.Windows.PalettePersistEventArgs)
        Dim a As Double = _
            CType(e.ConfigurationSection.ReadProperty("GESBP", 22.3), Double)

    End Sub
    Private Shared Sub ps_Save(ByVal sender As Object, _
                           ByVal e As Autodesk.AutoCAD.Windows.PalettePersistEventArgs)

        e.ConfigurationSection.WriteProperty("GESBP", 22.3)

    End Sub

 

GESBP is the name of the function and the commandmethod calling the palette. For the ps_load and ps_save I don't understand what I'm doing. What is double value use for? For the ps_Save there is also a 32.3 in the original document so I try both value but I think is a mispelled value.

 

Next I created my palette set using a GUID like this:

 

m_bps = New Autodesk.AutoCAD.Windows.PaletteSet("Palette des blocs", New Guid("{dcc7028a-d010-48e8-ae1c-8df9d0f7b111}"))

 

I start AutoCAD in debug mode. The first time I start AutoCAD (2012), there is no problem. The next time, AutoCAD hang at startup. I had to reset the current profile to succed to start AutoCAD again.

 

What I'm doing wrong???

 

Regards,

 

André

 

 

6 REPLIES 6
Message 2 of 7
Balaji_Ram
in reply to: andre_adc-dao

Hi André,

 

To only have the position of the paletteset saved and restored, you do not need the ps_save and ps_load. AutoCAD will save and restore the position if you have a GUID associated with the paletteset. 

 

I have attached a simple paletteset sample project that worked ok in AutoCAD 2012. Please notice the "AddHandler" to subscribe to the paletteset Load and Save events in case you need them.

 

Regards,

Balaji

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 7
Balaji_Ram
in reply to: andre_adc-dao

Just wanted to add :

 

"32.3 in the original document so I try both value but I think is a mispelled value."

 

That is not mispelled. 32.3 is the value that is being saved. When retrieving the value, you will still get back 32.3. The "22.3" used with "ReadProperty" as a default value that we want the method to provide us if nothing was saved earlier.

 

Hope this clarifies.

 

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 4 of 7
andre_adc-dao
in reply to: Balaji_Ram

Hi Balaji,

 

I run you TestPalette on AutoCAD 2012 (FRENCH). The first time it's ok. The next time I start AutoCAD, it is freezing, but not completely. After a certain time it continue and this is the message at the command line.

 

«Commande: Test TESTERBLOC ** La commande TESTERBLOC est autorisée dans
l'éditeur de blocs uniquement. **

Commande: Palette Commande inconnue "PALETTE".  Appuyez sur F1 pour obtenir de
l'aide.

Commande: Set
Commande inconnue "SET".  Appuyez sur F1 pour obtenir de l'aide.»

Notice it seems to try to send the name of the palette "Test Palette Set" as command to the command line. And the palette is not showing automatically. If I load the dll and start the command "MyPalette", the palette is showing at the last position I move it.

 

The only think I change in your code is the reference to acmgd and acdbmgd to point to AutoCAD 2012 installation.

 

Regards,

 

André

 

Message 5 of 7
Balaji_Ram
in reply to: andre_adc-dao

Hi  André,

 

I could reproduce the behavior of the paletteset name being sent to the command line when an undocked paletteset position was changed and AutoCAD restarted. If the position was not changed, the "Unknown command" messages in the command line do not appear. I have logged this in our internal database for our engineering team to analyze this behavior.

 

Sorry, I do not have a workaround to suggest for it.

 

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 6 of 7
andre_adc-dao
in reply to: Balaji_Ram

Hi Balaji,

 

I think I found a workaround. First I try to do a save/load settings by myself and I realize that is a lot of work and I was not satisfy by the result. So I decide to return to the source and dig a little deeper. I try this:

 

m_bps = New Autodesk.AutoCAD.Windows.PaletteSet("", New Guid("{dcc7028a-d010-48e8-ae1c-8df9d0f7b111}"))

m_bps.Text="Palette des blocs"

 

I set a GUID but witn an empty string as name and it seem to works very well. No «Unknown command» at startup and location and settings are automatically save and restore.

 

Thank you,

 

Regards,

 

André

 

Message 7 of 7
Balaji_Ram
in reply to: andre_adc-dao

Hi André,

 

Thank you for sharing the workaround that you found.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

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