.NET

Reply
Contributor
||||||||||
Posts: 11
Registered: ‎10-24-2006
Message 1 of 13 (201 Views)

Programatically Activating my ToolPalette

201 Views, 12 Replies
10-24-2006 09:02 AM
Hi All,
I've installed my product which loads a few toolpalettes & toolpalettesets. On first start I would like to open the toolpalette to my new toolpalette in code.

I can open the toolpalette by sending "TP" command, but this just opens the palette windo to the last used palette. I cannot figure out a way to 'Activate' or Focus my new toolpalette. I need to SetCurrent on it.

I've tryed PaletteSet.Activete(). Fails.

Any Ideas?
Valued Contributor
pavlos.katsonis
Posts: 67
Registered: ‎09-12-2006
Message 2 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

10-24-2006 01:43 PM in reply to: ||||||||||
I use the following code to activate the palette from a palette set (where palette points to the instance of the palette I want to activate):
[code]
System.Collections.IEnumerator paletteEnum = palette.PaletteSet.GetEnumerator();
for (int i = 0; paletteEnum.MoveNext(); i++)
if (((Palette)paletteEnum.Current).Name.Equals(palette.Name))
{
palette.PaletteSet.Activate(i);
break;
}
[/code]

As you can see Activate(int) works for me.
Contributor
||||||||||
Posts: 11
Registered: ‎10-24-2006
Message 3 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

10-25-2006 10:33 AM in reply to: ||||||||||
Hi Pavlos,
Thanks for the information.
I have a new issue that is similar.
I have created a partial cui with my menus & toolbars.
I then install it into the acad.cui by the following code...

CustomizationSection acadcui = new CustomizationSection(acad_fp);
CustomizationSection swatchdigitalcui = new CustomizationSection(swatchdigital_fp);

if (acadcui.PartialCuiFiles.Contains(swatchdigital_fp) == false)
{
acadcui.PartialCuiFiles.Add(swatchdigital_fp);
acadcui.Save();
}


This does in face add the partial.cui into the main cui but....
It does not activate-it does not add the menu to the main menus.
Where I open the customize dialog, the file is listed but will only show up if I manually press 'Apply'.
I've tryed RefreshWorkspace(), MakeDirty(), etc.

Do you have any idea hope I can get the menu to show up programmatially without having th resort to writing them into the acad.cui directly?

Thanks,
CM
Valued Contributor
pavlos.katsonis
Posts: 67
Registered: ‎09-12-2006
Message 4 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

10-26-2006 02:29 AM in reply to: ||||||||||
I add my custom menus with the following code (it adds a submenu with some menuitems under the dimension menu).
[code]
AcadApplication app = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
AcadMenuBar menuBar = app.MenuBar;
AcadPopupMenu dimensionMenu = null;
//Find the dimension menu
for (int i = 0; i < menuBar.Count; i++)
if (menuBar.Item(i).TagString.Equals("ID_MnDimensi"))
dimensionMenu = menuBar.Item(i);
if (dimensionMenu != null)
{
dimensionMenu.AddSeparator(dimensionMenu.Count);
AcadPopupMenu camSubMenu = dimensionMenu.AddSubMenu(dimensionMenu.Count, "CAM Dimensions");
camSubMenu.AddMenuItem(dimensionMenu.Count, "Square", "SQUAREDIM ");
camSubMenu.AddMenuItem(dimensionMenu.Count, "Sphere Radius", "SPHERERADIUS ");
camSubMenu.AddMenuItem(dimensionMenu.Count, "Sphere Diameter", "SPHEREDIAMETER ");
camSubMenu.AddMenuItem(dimensionMenu.Count, "Key", "KEYDIM ");
camSubMenu.AddMenuItem(dimensionMenu.Count, "Leader", "LEADERDIM ");
}
[/code]

As you can see I don't use a cui file, but the menu appears instantly.
Hope I could help you.
Contributor
||||||||||
Posts: 11
Registered: ‎10-24-2006
Message 5 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

11-08-2006 04:50 PM in reply to: ||||||||||
Now that I am trying it, I have a few questions.
1. How do I get a reference to my toolpalette in the first place??? Is this a ToolPalette or a Palette?
2. What is a PaletteSet ? Is it a PaleteGroup?

Thanks,
CM Message was edited by: ||||||||||
Valued Contributor
pavlos.katsonis
Posts: 67
Registered: ‎09-12-2006
Message 6 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

11-08-2006 10:19 PM in reply to: ||||||||||
The window you create, that hosts the various tabs is a paletteset (like the MATERIALS palette set). After you create the paletteset, you add controls (palettes) to it (like "Woods and Plastics - Materials Sample" palette in the above paletteset). When you add a control to a palette set, you get back a reference to the new palette as the return value of the Add method.
Contributor
||||||||||
Posts: 11
Registered: ‎10-24-2006
Message 7 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

11-09-2006 04:37 AM in reply to: ||||||||||
I see - but I am not creating the palettes programatically.
They are imported from exported palettes.
So my question is how to I get a palette reference from a set of existing palettes.
Basicly I have a palette called "SD Commands" which is one of 45 palettes I have imported.
Is there a way to get it?
I've tryed ToolPalette Manager.Find(Guid) which gives me a 'Catalog Item' which I tryed to cast to Palette. This failed.

Can I walk through existing palletes?

Thanks
CM
Valued Contributor
aslam
Posts: 86
Registered: ‎07-22-2006
Message 8 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

11-14-2006 01:45 AM in reply to: ||||||||||
Hi Guys,
Sorry for interrupt, but think you can give the answer of my question which i have posted so many times.

I have made a toolbar by using Autocad Tools->Customization and add made a toolbar in partial cui file. I have also made a Menu bar in that partial Cui file. Now i want to make an option in Menubar by which i can show or hide toolbar programatically. Can you help me how to do so by programatically.
Contributor
||||||||||
Posts: 11
Registered: ‎10-24-2006
Message 9 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

11-15-2006 12:29 PM in reply to: ||||||||||
Hi Aslam,
Try this link...
http://through-the-interface.typepad.com/through_the_interface/2006/11/loading_a_parti.html
Kean wrote a great artitlce about hiding & showing toolbars & menus from cui's.

Cheers,
CM
Valued Contributor
aslam
Posts: 86
Registered: ‎07-22-2006
Message 10 of 13 (201 Views)

Re: Programatically Activating my ToolPalette

11-16-2006 09:00 PM in reply to: ||||||||||
Thanks,
My Problem resolved.
A small Problem more. Could you help me plz.
How to check if current open (active window) drawing in Autocad is Saved (user has already clicked on save and no changes made yet) Or Not Saved?
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.