[Closed] Renaming object shortcut
I dont know wheter or not there’s already a shortcut in max or function for that but is there a way to make a script so when I press f2 or any other button I can rename an object in the name and color rollout?
Should I use HWND or should I simply make a quick rollout popup with the current name?
Depends, the popup is easier and universal, with the hwnd approach, you have a lot of things to take care of… for example,
(
fn getWindowClass =
(
source = "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "public class Window
"
source += "{
"
source += " [DllImport(\"user32.dll\")]
"
source += " public static extern IntPtr SetFocus(int hWnd);
"
source += "}
"
csharpProvider = dotNetObject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotNetObject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.GenerateInMemory = true
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
compilerResults.CompiledAssembly.CreateInstance "Window"
)
if NOT isKindOf ::window dotNetObject do window = getWindowClass()
if selection.count == 1 do
(
if NOT cui.commandPanelOpen do cui.commandPanelOpen = true
setCommandPanelTaskMode #create
local rollupHwnd = (windows.getChildHwnd #max "Name and Color")[2]
local hwnds = windows.getChildrenHWND rollupHwnd
local hwnd = for hwnd in hwnds where hwnd[4] == "#32770" do exit with hwnd[1]
window.SetFocus hwnd
)
)
would work when the command panel is docked, when not, you’d have to check for children of 0P instead of #max. On the other hand, it’s most probably what an unsuspecting artist would expect to happen from a rename shortcut.
nvm made my own dotnet form that open when executing a macroscript mapped to a shortcut
your solution works better than mine
My only issue with my current oslution is that my form doesnt stay on top of max when I do opetation like orbit or whatever
Like this?
form = dotNetObject "MaxCustomControls.MaxForm"
form.TopMost = true
form.Show()
actually I changed show to showModeless and it fixed my issue, my “last” is that the name doesnt update as the selection change so I might need to hook a callback and need to map the esc to close the form if needed and abort.
Nothing really hard there, thanks