.net palette problem

This widget could not be displayed.

.net palette problem

Anonymous
Not applicable
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

 

 
0 Likes
Reply
1,057 Views
4 Replies
Replies (4)

Anonymous
Not applicable

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.

0 Likes

Anonymous
Not applicable

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?

0 Likes

norman.yuan
Mentor
Mentor

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:

 

http://drive-cad-with-code.blogspot.com/2010/09/command-method-static-or-not-static.html

 

HTH.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes

Anonymous
Not applicable

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 

0 Likes