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

Programatically Activating my ToolPalette

12 REPLIES 12
Reply
Message 1 of 13
||||||||||
803 Views, 12 Replies

Programatically Activating my ToolPalette

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?
12 REPLIES 12
Message 2 of 13

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.
Message 3 of 13
||||||||||
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
Message 4 of 13

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.
Message 5 of 13
||||||||||
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: ||||||||||
Message 6 of 13

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.
Message 7 of 13
||||||||||
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
Message 8 of 13
aslam
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.
Message 9 of 13
||||||||||
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
Message 10 of 13
aslam
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?
Message 11 of 13
rubendm
in reply to: ||||||||||

Hi Pavlos,
First of all, thanks for the example. It was very useful for me. But I have a little problem. The separators aren't being added to the menu I modifying (View menu). Is it happening to you, too?

I am using AutoCAD and ObjectArx2006.

Thanks in advance 🙂

Rubén
Message 12 of 13

I have no such problem, but I use version 2007. I can't help you with 2006 since I've not tried its ObjectARX, but - if you fail to correct it - I believe you could live without a seperator 🙂
Message 13 of 13
Anonymous
in reply to: ||||||||||

Did you every solve this

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