Active Member
Posts: 8
Registered: ‎08-20-2011
Message 1 of 5 (480 Views)

.net palette problem

480 Views, 4 Replies
08-20-2011 02:57 AM
I am using Visual studio 2005 and autocad 2007
Here is the problem:
I follow the tutorial CP205-2 (Creating a Docking Palette for AutoCAD® with VB.NET)
At step 7 i compile and netload.
The palette appears docked, everything's fine
When i drag it to undock comes the disaster: The palette disappears. Sometimes autocad hangs after that. Sometimes the palette appears (after undocking) to have the same width as autocad but locked and acts like crazy.
Here is the code: 
Imports Autodesk.AutoCAD.Runtime
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


Valued Mentor
Posts: 321
Registered: ‎05-12-2009
Message 2 of 5 (474 Views)

Re: .net palette problem

08-20-2011 03:21 AM in reply to: mikefr

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.

You can also find your answers @ TheSwamp
Active Member
Posts: 8
Registered: ‎08-20-2011
Message 3 of 5 (461 Views)

Re: .net palette problem

08-20-2011 04:55 AM in reply to: jeff

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?

*Expert Elite*
Posts: 946
Registered: ‎04-27-2009
Message 4 of 5 (446 Views)

Re: .net palette problem

08-20-2011 06:48 AM in reply to: mikefr

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:







Active Member
Posts: 8
Registered: ‎08-20-2011
Message 5 of 5 (443 Views)

Re: .net palette problem

08-20-2011 06:59 AM in reply to: norman.yuan

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?

Thank you 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community