Notifications
Clear all

[Closed] measure floater

Hello scripting gurus,
Was looking for a script to invoke the “measure floater” by bypassing the utilities panel and found this one from Bobo, which is a few versions old and doesnt seem to be working on 2016. Since I dont know squat about maxscript, would anyone be kind enough to take a look a it and tell me how to fix it?

[I]macroScript OpenMeasureFloater
category:“Forum Help”
buttontext:“Measure!”
tooltip:“Open the Measure Floater with one click!”
(
fn openMeasureFloater =
(
WM_SETREDRAW=0xB
commandHWND = windows.getChildHWND #max “Command Panel”
windows.sendmessage commandHWND[1] WM_SETREDRAW 0 0
local result = false –flag for success/failure
local oldPannel = getCommandPanelTaskMode() –remember the old command panel tab
UtilityPanel.OpenUtility measure –open Utility tab and enable Measure Utility
local theMeasureUtil = windows.getChildHWND #max “Measure” –grab the Measure’s rollout handle
if theMeasureUtil.count > 0 do –if it was found,
(
local theButton = windows.getChildHWND theMeasureUtil[7] “New Floater” –get the New Floater button’s handle
print theButton
if theButton.count > 0 do –if this succeeded too, then send messages to click it
(
Windows.sendMessage theButton[1] 0x201 0 0 –Left Mouse Button Down
Windows.sendMessage theButton[1] 0x202 0 0 –Left Mouse Button Up
result = true –raise the flag for success
)
)
setCommandPanelTaskMode oldPannel –switch back to the previous command panel tab
windows.sendmessage commandHWND[1] WM_SETREDRAW 1 0
result –return result
)

openMeasureFloater()
)
[/I]
Huge thanks!

12 Replies

It works fine here.
Do you use a localized Max version?

Thanks for responding!

Localized Max version? What do you mean by that?

I mean a different language than English for the UI.

The script relies on the Labels of the controls. So it looks first for a control with label “Measure” and then for a button labeled “New Floater”.

This is for English version, but for other languages the labels might be different and so the script can’t find them.

All english here.

I get a : -No “get” function for undefined- comment when running the script

Ok, hard to tell what it might be. See if this works:

macroScript OpenMeasureFloater
 category:"Forum Help"
 buttontext:"Measure!"
 tooltip:"Open the Measure Floater with one click!"
 (
 	fn openMeasureFloater =
 	(
 		--WM_SETREDRAW=0xB
 		--commandHWND = windows.getChildHWND #max "Command Panel"
 		--windows.sendmessage commandHWND[1] WM_SETREDRAW 0 0
 		--local result = false --flag for success/failure
 		local oldPannel = getCommandPanelTaskMode() --remember the old command panel tab
 		UtilityPanel.OpenUtility measure --open Utility tab and enable Measure Utility
 		local theMeasureUtil = windows.getChildHWND #max "Measure" --grab the Measure's rollout handle
 		if theMeasureUtil.count > 0 do --if it was found,
 		(
 			local theButton = windows.getChildHWND theMeasureUtil[7] "New Floater" --get the New Floater button's handle
 			if theButton.count > 0 do --if this succeeded too, then send messages to click it
 			(
 				Windows.sendMessage theButton[1] 0x201 0 0 --Left Mouse Button Down
 				Windows.sendMessage theButton[1] 0x202 0 0 --Left Mouse Button Up
 				result = true --raise the flag for success
 			)
 		)
 		setCommandPanelTaskMode oldPannel --switch back to the previous command panel tab
 		--windows.sendmessage commandHWND[1] WM_SETREDRAW 1 0
 		--result --return result
 	)
 
 	openMeasureFloater()
 )

Still no go.
Now getting : unknown property “count” in undefined
Would the fact that my command panel is on another monitor have anything to do?

Thanks again for taking the time, Jorge. Much appreciated!

I see. You have the Command Panel undocked.
This should work with both docked and undocked Command Panel (I hope)

macroScript OpenMeasureFloater
       category:"Forum Help"
       buttontext:"Measure!"
       tooltip:"Open the Measure Floater with one click!"
       (
       	
       	fn openMeasureFloater =
       	(
       		WM_SETREDRAW = 0xB
       		WM_LBUTTONUP = 0x202
       		WM_LBUTTONDOWN = 0x201
       
       		local result = false
       		local oldPannel = getCommandPanelTaskMode()
       		
       		commandHWND = windows.getChildHWND #max "Command Panel"
       		if commandHWND == undefined do commandHWND = windows.getChildHWND 0P "Command Panel"
       		
       		windows.sendmessage commandHWND[1] WM_SETREDRAW 0 0
       		
       		UtilityPanel.OpenUtility measure
       		
       		local theMeasureUtil = windows.getChildHWND #max "Measure"
       		if theMeasureUtil == undefined do theMeasureUtil = windows.getChildHWND (windows.getDesktopHWND()) "Measure"
       
       		if theMeasureUtil != undefined do
       		(
       			local theButton = windows.getChildHWND theMeasureUtil[7] "New Floater"
       			
       			if theButton != undefined and theButton.count > 0 do
       			(
       				Windows.sendMessage theButton[1] WM_LBUTTONDOWN 0 0
       				Windows.sendMessage theButton[1] WM_LBUTTONUP 0 0
       				result = true
       			)
       		)
       		setCommandPanelTaskMode oldPannel
       		windows.sendmessage commandHWND[1] WM_SETREDRAW 1 0
       		return result
       	)
       	
       	openMeasureFloater()
       	
       )

[b]The above code is a modified version of a Script created by Borislav Petrov (Bobo).

[/b]

Working!
Cant thank you enough, Jorge. This is gonna save me a lot of clicking around.
And it’s about time I started delving into maxscripting…

Thanks again

Hi, This is great thanks. I use it.
I am a novice at maxscript .
But I would like to position the Measure Floater in a corner or on the next screen. I think this should be possible with the offset :[1000, 400] or using the “pos:” command . I keep getting undefined errors.

Page 1 / 2