Imports Autodesk.AutoCAD.Windows Public Class Class1 Public myPaletteSet As PaletteSet Public myPalette As UserControl1 <CommandMethod("run")> _ Public Sub run() If myPaletteSet = Nothing Then myPaletteSet = New PaletteSet("Test") myPalette = New UserControl1 myPaletteSet.Add("My first palette", myPalette) myPaletteSet.Visible = True End If myPaletteSet.Visible = True End Sub End Class
It might have something to do with your setup and how AutoCAD will create a new instance of that class since it has the CommandMethod attribute.
I downloaded the objectARX sdk 2007 and used (reference) the dlls from the "inc" folder and it works fine (phiou).
Before that i used the dlls from "program files\autocad 2007" folder and had the problem. Why is that?
There are two things you would want to try:
1. Pass a constant Guid value to PaletteSet constructor.:
myPaletteSet = New PaletteSet("Test", New Guid("AN1356J1-3052-A182-72347G840HN0"))
Note: you should generate a new Guid with VisualStudio, do not re-use existing one.
This way, AutoCAD will be able to remember the PaletteSet's posistion/size and ist docking status when Acad closes and restore the PaletteSet in new Acad session.
Without the Guid argument used in the constructor, the PaletteSet is alway shown docked the first time you open it in an Acad session and have an unpredictable size/location when you drag it undocked.
2. The PaletteSet should be decleared as static (Shared in VB.NET). You only want to have one instance of the PaletteSet in current AutoCAD session.
The command method that creates PaletteSet should be static/Shared method. Otherwise (as your code), when your run the "run" command (with different drawings), your PaletteSet would be instanced for EACH drawing. For this topic, see my article here:
Thank you for your tips, now that the palette works fine i'm going to try them. But why when i used the dlls from autocad folder there was a problem and when i used the abjectARX dlls everyhting was fine?
Also, what about compability? Can my assembly work with newer or earlier versions of autocad?
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register