CustomUI

 From:  Max Smirnov (SMIRNOV)
6507.1 
Hi!
I would like to present my new scripts :) CustomUI project.
Using it you can add a custom buttons and menus to CommandBar.
!!! The latest version works only with MoI v.3.0 !!! V.1.03 is not compatible with MoI v.4 beta, use v2.0 beta instead (http://moi3d.com/forum/index.php?webtag=MOI&msg=6507.268)





Advantages of CustomUI:
1. CustomUI adds only one line to the CommandBar.htm file.
2. Flexible module structure
3. All CustomUI files stored separately from MoI files. (in other words, you can delete it in one second :)

Installation:
- Backup /ui/CommandBar.htm
- Extract CustonUI archive into the MoI directory
- Run moi.exe

Files description:
"objects" - Object library directory (contains some demo objects).
"snapshots" - directory where Snapshot addon stores snapshots
/ui/CommandBar.htm - replaces original CommandBar.htm file
/ui/EmptyStrings.txt - empty language file (Snapshot addon uses this file to switch on/off a viewport labels (Front/Left/3D etc.) for taking clean screenshots. Michael, please make something like moi.view.showViewportLabels )
/ui/customui/-05 Select.htm ..... /ui/customui/88 LightingPresets.htm - buttons/menus modules
/ui/customui/CustomInit.js - CustomUI initialization script
/ui/customui/mods/ - directory for additional scripts/configs/menus data.. etc.

Usage:
Go to the /customui directory and select modules which you want to use. To disable module, just put "-" symbol at the beginning of a filename (most of modules are already disabled).
-45 History.htm - history button disabled
45 History.htm - history button enabled
You can change buttons order by editing a two digit numbers in filenames. 00 - will be first, 99 - last.

Note: I use BASE64 encoding to store icons directly in htm file intstead of creating a png-file.

Almost all modules executes a built-in MoI commands (copy, paste, hide, lock .....). But I wrote four addons to show a real power of this system.

ObjLibrary
---------------
With this addon you can add an objects to object libraries.
Select object(s). Open Library menu. Click to the Library name (+ symbol appears). Enter object name. All selected objects will be added as single library object.
If no objects is selected, all objects will be saved to the library as single object.
To import objest: Open Library, Left click - import object (import part command). Right click - fast import (import command).
Use the middle mouse button to rename object. Leave name field blank and press OK to delete the object.

You can use any directory as library. Edit /customui/mods/ObjLibrary.cfg.htm with notepad to add/delete libraries.
ObjLibrary.cfg.htm is a plain text file with comma-separated values.
Library name,Full path to the directory (";" symbol is also accepted)
*) You can use MOI abbreviation instead of full path to point to the MoI directory
Examples:
Local objects;MOI\objects
Dropbox;C:\Users\DropboxUser\Dropbox\MoI library
Hint: To get the full path of a folder in Windows, hold Shift, Right click and select "Copy as path"

ExtScripts
--------------
This addon dynamically generates list of all external scripts. Also it adds to the list some "hidden" MoI commands.
There is another version of this addon - ExtScriptsFull. It works exactly as ExtScripts, but It loads all MoI commands.
You can open ExtScripts.menu.htm(ExtScriptsFull.menu.htm) with Notepad and edit "maxlines" value ( default 40 ) to change the maximum number of lines.
By default this addon checks only /commands directory, but you can create /customui/mods/ExtScripts.cfg.htm with notepad to add any directory you want.
Example:
MOI\commands
MOI\commands\myscripts
MOI\myscripts2
D:\dir1\dir2\myscripts3

Note: As you noticed (or maybe not), I always use "_" symbol in the beginning of my scripts names. Using this trick I can easily find and manage external scripts in /command directory.
ExtScripts automatically removes "_" symbol, so "_vClone" script will be shown as "vClone".

Snapshot
-------------
With this addon you can make a snapshot of last clicked viewport.
Resolution is fixed: 1600x1200
Left click - grid is visible
Right click - grid is hidden
Shift + click = resolution x 2
Ctrl + Shift + click = resolution x 3
Snapshots will be saved to "snapshots" directory.

LightingPresets
---------------------
This addon can be used only with Lighting Options plugin (by Dinos). Great plugin! Thanks Dinos.
Use Lighting options to create a lighting presets. After that you can switch presets on the fly using this addon.

Update history:
1.0 Initial release
1.01 ObjLibrary.menu.htm - Now, while making an icon the script hides all unselected objects.
1.02 All scripts have been rewritten using newest filesystem functions.
1.03 Fixed "flashing" effect while taking a snapshot; Added the ability to specify ExtScripts directories.

EDITED: 7 Mar 2022 by SMIRNOV