Author Topic: How to get the current index of paletteset?  (Read 1506 times)

0 Members and 1 Guest are viewing this topic.

guohq

  • Newt
  • Posts: 84
How to get the current index of paletteset?
« on: December 25, 2013, 06:06:10 AM »
There'er four palettes in  paletteset.I can set the acitve palette use mouse.how can I get the current index of paletteset by code?

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: How to get the current index of paletteset?
« Reply #1 on: April 02, 2014, 04:46:17 AM »
I think the index is not need for you in this case. For example, you can to get necessary Palette via such code:
Code - C#: [Select]
  1. using Wn = Autodesk.AutoCAD.Windows;
  2. ...
  3. public static class PaletteSetExtentions {
  4.   /// <summary>
  5.   /// Get Palette by its name
  6.   /// </summary>
  7.   /// <param name="ps">Owner (PaletteSet)</param>
  8.   /// <param name="name">Palette's name</param>
  9.   /// <returns>Returns the Palette or null if is not exist.</returns>
  10.   public static Wn.Palette GetPalette(this Wn.PaletteSet ps, String name) {
  11.     if (name == null || name.Trim() == String.Empty)
  12.       return null;
  13.     foreach (Wn.Palette item in ps)
  14.       if (item.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
  15.         return item;
  16.     return null;
  17.   }
  18. }