.NET

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

.net palette problem

456 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: 319
Registered: ‎05-12-2009
Message 2 of 5 (450 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
mikefr
Posts: 8
Registered: ‎08-20-2011
Message 3 of 5 (437 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: 893
Registered: ‎04-27-2009
Message 4 of 5 (422 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:

 

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

 

HTH.

 

 

Active Member
mikefr
Posts: 8
Registered: ‎08-20-2011
Message 5 of 5 (419 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

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community