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

Problem with PaletteSet location in Autocad

24 REPLIES 24
Reply
Message 1 of 25
JernejC
1902 Views, 24 Replies

Problem with PaletteSet location in Autocad

I'm having problem with chosing PalleteSetSet location in Autocad. No matter what I do, it is always docked on left side of Autocad window. My code is something like this:

PaletteSet ps;
ps = new PaletteSet("blabla", new Guid(System.Guid.NewGuid().ToString("B")));
ps.Style = PaletteSetStyles.NameEditable | PaletteSetStyles.ShowPropertiesMenu |
PaletteSetStyles.ShowAutoHideButton | PaletteSetStyles.ShowCloseButton;
ps.MinimumSize = new System.Drawing.Size(Width,Height);
ps.Size = new System.Drawing.Size(.Width,Height);
ps.DockEnabled = Autodesk.AutoCAD.Windows.DockSides.None;
ps.Add("blabla", new Palette());
ps.Visible = true;

Am I missing something? Edited by: JernejC on Sep 25, 2009 8:42 AM
24 REPLIES 24
Message 2 of 25
Anonymous
in reply to: JernejC

Because you use "new Guid()" each time the PaletteSet is created. AutoCAD
persists PaletteSet's location using the GUID assigned to the PaletteSet as
identifier. You should get a fixed Guid value for your PaletteSet.

"JernejC" wrote in message news:6260920@discussion.autodesk.com...
I'm having problem with chosing PalleteSetSet location in Autocad. No matter
what I do, it is always docked on left side of Autocad window. My code is
something like this:

PaletteSet ps;
ps = new PaletteSet("blabla", new
Guid(System.Guid.NewGuid().ToString("B")));

ps.Style = PaletteSetStyles.NameEditable |
PaletteSetStyles.ShowPropertiesMenu |

PaletteSetStyles.ShowAutoHideButton |
PaletteSetStyles.ShowCloseButton;

ps.MinimumSize = new System.Drawing.Size(Width,Height);
ps.Size = new System.Drawing.Size(.Width,Height);
ps.DockEnabled = Autodesk.AutoCAD.Windows.DockSides.None;
ps.Add("blabla", new Palette());
ps.Visible = true;

Am I missing something?

Edited by: JernejC on Sep 25, 2009 8:42 AM
Message 3 of 25
JernejC
in reply to: JernejC

Which "new Guid()" is a problem?
1.) System.Guid.NewGuid().ToString("B") or
2.) new PaletteSet("blabla", new Guid(...))

I tried setting fixed Guid in first case but there are still no changes. In second case I don't know if there is any other way...
Message 4 of 25
Anonymous
in reply to: JernejC

You need to use the same constant string when
you create the GUID:

{code}

Guid guid = new Guid(""255AA27F-A408-48d5-AA06-F311F3027A9D");

PaletteSet ps = new PaletteSet( "commandname", guid );

You can generate the string for the GUID from Visual Studio's GUIDGEN
tool, which is available from the Tools menu (Tools->Create GUID).

The important thing is that the GUID string must be constant and unique
for each paletteset, and should never change.

Sorry if this post is unreadable, I can assume no responsibility for the
gross incompetence that underlies Autodesk's online discussion group
software.



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6263127@discussion.autodesk.com...
Which "new Guid()" is a problem?
1.) System.Guid.NewGuid().ToString("B") or
2.) new PaletteSet("blabla", new Guid(...))

I tried setting fixed Guid in first case but there are still no changes. In
second case I don't know if there is any other way...
Message 5 of 25
JernejC
in reply to: JernejC

Ok, thank you very much.
Message 6 of 25
ZK_BUDiKOM
in reply to: JernejC

Hi,

 

I have created my GUID, and I'm trying to compile my code.
But always is the same error message:

 

Error 1 The type 'System.Windows.Interop.IWin32Window' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. C:\C#_Projects\test8\PreviewBox\PreviewBox\Class1.cs 30 20 PreviewBox

 

I have MVS2010 and AutoCAD2013.

Net framework 4.0.

 

What I should to do?

 

regards

Message 7 of 25

Hi,

 

the message shows you:

>> You must add a reference to assembly 'PresentationCore [...]

have you done that?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 8 of 25

Hmm...

no, I did not...

after the addition, works 🙂

 

I had to also add "static" in this line:

static Guid guid = new Guid("2919D05C-3A64-4098-B465-FCE445CBD1C7");
PaletteSet myPal = new PaletteSet("commandname", guid);

 

I test this example:

http://blog.smitec.net/posts/autocad-dwg-preview-control/

code:

https://github.com/smitec/AutocadPreviewBox

 

thank you alfred.

Message 9 of 25
ZK_BUDiKOM
in reply to: ZK_BUDiKOM

Hmm...

 

this code is correctly compiled, but if I want to add DWG file, AutoCAD generates an error.
What is wrong?

 

regards

 

 

Message 10 of 25

Hi,

 

what I see when I open your project (have not started it at all):

  • you have set the property "local copy" for the references to "yes" ==> that should be "no"
  • how do you debug your project? When going to project-properties you have not set the "external program to start" to your ACAD.EXE or to the ACCORECONSOLE.EXE.

 

Interesting would be to see what message you get? Upload a screenshot from this message.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 11 of 25

  • you have set the property "local copy" for the references to "yes" ==> that should be "no"

Where is this position?

 

  • how do you debug your project? When going to project-properties you have not set the "external program to start" to your ACAD.EXE or to the ACCORECONSOLE.EXE.

OK.

I've added acad.exe.

 

After Debug (F5), AutoCAD2013 run and show me the error message:

 

Application does not support just-in-time (JIT)
debugging. See the end of this message for details.

************** Exception Text **************
System.InvalidCastException: Unable to cast object of type 'Autodesk.AutoCAD.LivePreview.PreviewRuleProvider' to type 'Autodesk.AutoCAD.Internal.IPreviewContextProvider'.
at Autodesk.AutoCAD.LivePreview.PreviewContextService.LoadContext()
at Autodesk.AutoCAD.LivePreview.PreviewContextService.get_ContextProvider()
at Autodesk.AutoCAD.LivePreview.PreviewContextManager.OnIdleInitialize(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at Autodesk.AutoCAD.ApplicationServices.Core.Application.OnIdle()


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.296 (RTMGDR.030319-2900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
Acdbmgd
Assembly Version: 19.0.0.0
Win32 Version: 19.0.55.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202013/AcdbMgd.DLL
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.296 built by: RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0

 

 

I load my DLL (netload) and write PREV.

I see My Palette.

I write LDPRV, and error.

 

regards

Message 12 of 25
ZK_BUDiKOM
in reply to: ZK_BUDiKOM

OK. I have found this "local copy".
I changed to "False".

Now, F5 (Debbug) doesn't generate an error, but still is when I write LDPRV.

 

 

 

 

 

Message 13 of 25

Hi,

 

>> Now, F5 (Debbug) doesn't generate an error, but still is when I write LDPRV.

Ok, then next step is to tell the debugger to stop on all errors. Do that in Visual-Studio ==> pull-down-menu "debug" ==> item "exceptions" (hope that the translation from my German version is ok for that words) and within this dialog check "Common Language Runtime Exceptions".

 

 

Now exceptions raised during code will break the debugger and show you the position where the exception occured.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 14 of 25

It's done.

 

 

 

 

 

I have found description this exception:

http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(EHNULLREFERENCE);k(TargetFr...

 

Do you have any idea what now?

 

regards

Message 15 of 25

Hi,

 

myPreviewBox is never set to an object (never instanciated) as this.Preview is never started.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 16 of 25

Hmm...

 

in an example was:

/// <summary>
/// Instance of the Preview box
/// </summary>
PreviewBox myPreviewBox;

 

I have changed to:

PreviewBox myPreviewBox = new PreviewBox();

 

and now, the error is here:


 

 

maybe this example is incorrect and I never won't run this project?...

 

regards

Message 17 of 25

Hi,

 

does that happen with all drawings? Have you set your AutoCAD to "not save the thumbnails"?

The error seems to raise when the line above does not return a valid object (variable preview). So either there is no image in the file or the function does not return a bitmap.

(have not tried your code, so that's just guessing)

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 18 of 25
ZK_BUDiKOM
in reply to: ZK_BUDiKOM

When I comment this line:

//grab the thumbnail bitmap and get rid of the white background
System.Drawing.Bitmap preview = dbb.ThumbnailBitmap;
//preview.MakeTransparent(System.Drawing.Color.White);

 

program run propertly, but view nothing in "My Palette"...

AutoCAD 2013 - NOT FOR RESALE - [Drawing1.dwg].jpg

 

I added Alert in this place:

Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("\nAlert " + fn.StringResult);
//use the loaded dwg file to update the preview box
myPreviewBox.load_file_preview(fn.StringResult);

 

and show me path to my DWG file - is correct, eg. "c:\Blocks\My_blok.dwg".

 

"does that happen with all drawings?" - Yes.

Have you set your AutoCAD to "not save the thumbnails"? - where can I set this?

 

regards

 

 

Message 19 of 25

Hi,

 

>> Have you set your AutoCAD to "not save the thumbnails"? - where can I set this?

Command _OPTIONS ==> tab "Open and Save" ==> button "Thumbnail Preview Settings"

 

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 20 of 25

Hi,

 

Thumbnail Preview Settings.jpg

 

I have the same like you 🙂

 

regards

 

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