.net tool palette question

.net tool palette question

CAD-Geek
Advocate Advocate
2,888 Views
4 Replies
Message 1 of 5

.net tool palette question

CAD-Geek
Advocate
Advocate

Hi all
I create a AutoCAD tool palette using C#
I have two questions
1- how to change tool palette Icon instead of AutoCAD default Icon
2- How to add Items to tool Palette such as (blocks or Macro buttons)..
That's what I got

	public void CreateMyPalette()
		{
			if(ps == null)
			{
				ps = new Autodesk.AutoCAD.Windows.PaletteSet("Test"); 
				ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu
					| Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton
					| Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton;
				ps.Opacity = 90;
				ps.Size = new System.Drawing.Size(250,250);
				ps.MinimumSize = new System.Drawing.Size(225, 200);
                                ps.Add("P1", new UserControl1());
				ps.Add("P2", new UserControl2());
				ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Left;


				ps.Visible = true;
			}
			else
			{
				ps.Visible = true;
			}


		}
0 Likes
2,889 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

1. Autodesk.AutoCAD.Windows.PaletteSet has a read/write property "Icon". You can read any icon file of yours as System.Drawing.Icon and set to this property.

 

2. A PaletteSet can contain one or more Palettes, which are usually UserControl either from Win Form, or WPF. They can hold Controls of Win Forms/WPF, but no control by itself is "block" or "macro button".

 

By "block", I guess what you mean is a image/picture control, or a button with image, showing a shape of block, so that user clicks the image/button to do something related to certain block, such as insert a block, or the clicking triggers a commend.

 

So, you can place whatever controls you choose onto the UserControl, and handle the control's even, most likely the Click event. In the event handler, you let AutoCAD operating code runs, such as inserting block. Since PaletteSet is a floating/modeless window, it is often better to separate your custom AutoCAD data proecess logics into a set of custom commands and execute them in the PaletteSet's user interaction event handler with MdiActiveDocument.SendStringToExecute() method.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

mehdi.Autodesk
Contributor
Contributor

Hi Norman,

is it also possible to loop throw the existing tool Palettes or some how listen to event handler of existing Tools palette?

if yes would you an example function.

 

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor

While the title of this thread mentioned "tool palette", if you read the original post, it was about Autodesk.AutoCAD.Windows.PaletteSet class, not ToolPalatte, which is different from PaletteSet class. So, you may want to clarify which one you are talking about. By say "existing tool palettes", it seems you are talking about the latter. If so, sorry, I am not able to help.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 5

mehdi.hooshmandfard
Participant
Participant

Yes Norman you are right, actually want to refresh the Civil 3D sub assembly palette due to reload its binding and I didn't find a solution to refresh that. if you prefer I will close the topic here.

0 Likes