Sort by Hue, I should Coco

Nov 26, 2008 by     No Comments    Posted under: 3dsMax, DotNet, User Controls

Here is an update to the color chart article. Since custom UI controls are kinda my thang, I decided to make one for this. The above left is with the colors sorted by Hue (More about this below). On the right is the previous arrangement where they are sorted by name. The Hue sort isn’t perfect, but it does at least group similar colors together which makes it easier to pick rather than the random sort by name on the right. You pick colors generally by Hue, not by their name.

The advantages of building a custom control are a simpler maxscript implementation. As you can see below this is the code for building the ColorChart in 3ds Max –

dotnet.LoadAssembly "C:LoneRobotclasslibMaxColorControl.dll"
rollout ColorChart "LoneRobot MaxColorChart" width:340 height:610
dotNetControl LRColorChart "LoneRobot.UI.MaxColorControl" pos:[0,0] width:338 height:610
createdialog colorchart

Now that is minimal code! 😉

I was looking into using an IComparer interface for performing a Hue based color sort and found this article –

Thanks goes to Ruud van Eeghem for this posting.

Rather than writing one from scratch, I liked his GDI+ method of generating the color swatches, and since it was in C# I converted it to VB so that I could use it. Once that was done I added a few extra properties and methods to the control, namely taking the picked pixel color and checking to see if it was a ‘named’ dotnet color. Once I had this I made a composite control to extend the functionality and provide the clipboard method seen before. Bingo!

Update –

After a nights’ sleep I realized I wanted a more compact version. The control still displays the color name, but not the full maxscript string. The full string is still copied to the clipboard. You could register a dockable window for this. The new control is embedded into the same assembly, just change the dotnetcontrol declaration to “LoneRobot.UI.MaxColorControlMini”

download script