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

.net palette problem

4 REPLIES 4
Reply
Message 1 of 5
mikefr
937 Views, 4 Replies

.net palette problem

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

 

 
4 REPLIES 4
Message 2 of 5
jeff
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
Message 3 of 5
mikefr
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?

Message 4 of 5
norman.yuan
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:

 

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

 

HTH.

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5
mikefr
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 

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