[Closed] Changing value of WPF property
Actually there is another undocumented method of adding items to the QAT toolbar:
fn QATaddItem MacroScriptName Category =
(
maintoolbar_file = pathConfig.removePathLeaf((symbolicPaths.getPathValue "$userscripts")) + "\\ui\\MaxStartUI.cui"
--First save our current CUI file as the MaxStartUI.cui
deleteFile maintoolbar_file
cui.saveConfigAs maintoolbar_file
--Read Current Item count
QATItemCount = getINISetting maintoolbar_file "QATItems" "QATItemCount"
--Set value
setINISetting maintoolbar_file "QATItems" ("Item" + QATItemCount) ("647397|" + MacroScriptName + "`" + Category)
--Reload cui file
cui.loadConfig maintoolbar_file
)
Ok finally did it
Autodesk.Windows.ToolBars.QuickAccessToolBarSource strip = ComponentManager.QuickAccessToolBar; if (strip != null) { RibbonButton rb = new RibbonButton(); rb.Text = "test"; strip.AddStandardItem(rb); rb.Description = "Desc"; rb.Image = GetIcon(theImage); }
This adds button to quick launch bar.
EDIT: Managed to add new WPF panel like graphite modeling tools it works really awesome, still trying to add button to main max menu, i add item to menu i see empty space but it does not show icon or text but still working on it.
We might be going a bit offtopic here but, I just realized what a mess the whole QAT is…
There seem to be multiple ways of adding/removing stuff from the toolbar.
You can add/remove items from the Customize window or directly by changing the cui file and reloading. (or simply use qat.add)
But, you can also add items through the ribbon interface, right clicking items and clicking on “Add to QAT”. (You can also add separators by rightclicking in the QAT.)
But, NONE of the items added through the ribbon interface will be saved in the cui file, so they will not show up next time you run 3dsMax. So it’s… completly useless for the user?
Either you add items through the old Customize window, but you won’t be able to add all the items you want, and you won’t be able to change icons and other things.
Or… you add items through the ribbon interface, but they will be gone next time you start 3dsmax! :banghead:
What about a startup script? i did it with your snipplet to remove the call center stuff, it’s in my stdscripts folder and works great.
The whole max custom UI stuff is very unreliable anyway, the ribbon gets easily corrupted. It makes no sense for the user to customize it, because changes are not portable (all or nothing), and if it corrupts you have to start again.
Yep, I realized that as well. It is really slow as well… just switching between subselections in editable poly, takes away 1s to 2s 😮
A startup script that repopulates the QAT could be possible… but I’m wondering why would Autodesk give you the option to customize the QAT, if you can’t save the changes? :shrug:
Perhaps you can hook the “CollectionChanged” event of the toolbar’s Item collection and save off the state to the ini file when it changes?
fn PropertyWatcher sender args =
(
format "
changed property [%]
" args.PropertyName
)
fn CollectionWatcher sender args =
(
format "
Item collection has changed, action is [%]
" (args.action.ToString())
if args.NewItems != undefined do
(
format "There are % new items, starting at index %
" args.NewItems.count args.NewStartingIndex
)
if args.OldItems != undefined do
(
format "There are % old items, starting at index %
" args.OldItems.count args.OldStartingIndex
)
format "You will want to update the CUI ini file if you intend to make this change permanent...
"
)
qatbar =(dotnetclass "Autodesk.Windows.ComponentManager").QuickAccessToolBar
-- Clear out handler (if we excute this script more than once)
dotnet.removeeventhandlers qatbar "PropertyChanged"
dotnet.removeeventhandlers qatbar.items "CollectionChanged"
dotnet.addeventhandler qatbar "PropertyChanged" PropertyWatcher
dotnet.addeventhandler qatbar.items "CollectionChanged" CollectionWatcher
-- Trigger some property change events
qatbar.IsVisible = false
qatbar.IsVisible = true
rb = dotnetobject "Autodesk.Windows.RibbonButton"
-- Create an icon with the correct size
uri = dotnetobject "Uri" ((getdir #maxroot)+@"ui\Icons\ApplicationMenu\summaryInfo_32.ico") (dotnetclass "UriKind").Absolute
rb.Image = dotnetobject "System.Windows.Media.Imaging.BitmapImage"
rb.Image.BeginInit()
rb.Image.UriSource = uri
rb.Image.DecodePixelWidth = 16
rb.Image.DecodePixelHeight = 16
rb.Image.EndInit()
-- Trigger some item collection changed events
rb.id = (qatbar.items.count + 1000) as string -- Pick an unused ID
rb.Description = "A new button with ID " + rb.id
qatbar.AddStandardItem rb
rb = rb.Clone()
rb.id = (qatbar.items.count + 1000) as string
rb.Description = "A new button with ID " + rb.id
qatbar.AddStandardItem rb
rb = rb.Clone()
rb.id = (qatbar.items.count + 1000) as string
rb.Description = "A new button with ID " + rb.id
qatbar.AddStandardItem rb
/*
---Remove any 'extra' items
while qatbar.items.count > 6 do
(
qatbar.RemoveStandardItem qatbar.items.item[qatbar.items.count-1]
)
*/
Saving the state may not be useful in the end because you are probably going want to bind the click of the button you add to some maxscript function at startup anyhow.
.biddle
I managed to customize ribbon adding stuff but i agree ribbon control is so slow. But its nice that you can customize start up interface to something different… Its weird that so much is undocumented.
hmmmm… I was wondering… perhaps the 3dsmax icon on the upper left corner can be deleted? It seems to be inside AdImpApplicationFrame, but I can’t find anything that could make it invisible.
I have managed however to get rid of it by reshacking 3dsmax.exe and deleting the bmp’s of the button.