ScriptSpot

Forum topic · Scripts Wanted

Open the Measure Floater with one click

By piotrglabski · 2018-05-09

Description

Hi,
Is it possible to do this?
And without changing to Utilities Panel?
Just Measure Panel with Lock Selection On...

Or some other method do get live dimensions..?

I've checked miauu's tools, but they are to complex and not free...

Comments (8)

squeakybadger · 2018-10-09

This is what I have been using to open the Measuretool Floater for a while. Works in max 2018 & 2019.

No idea how to get it to start with the selection lock option enabled though! I'm sure I found it on scriptspot though.


(
	(

	fn openMeasureFloater =


		
	(
	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

	(
	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
	result --return result
	)

	openMeasureFloater()
	
	)
)

.

jahman · 2018-05-12

Sure it is possible.


(
	
	local mode = GetCommandPanelTaskMode()
	local subobjlvl = subObjectLevel
		
	UtilityPanel.OpenUtility Measure
	local commandPanelHwnd = (windows.getchildhwnd #max "Command Panel")[1]
	local childs = windows.getChildrenHWND commandPanelHwnd
	local newFloaterBtnHwhd
	
	for c in childs do ( 

		if c[4] == "Button" and c[5] == "New Floater" then newFloaterBtnHwhd = c[1] else 
		if c[4] == "Button" and c[5] == "Lock Selection" do (

			windows.sendMessage c[1] 0x201 1 0
			windows.sendMessage c[1] 0x202 0 0
			
		)

	)
	if newFloaterBtnHwhd != undefined do UIAccessor.PressButton newFloaterBtnHwhd

	SetCommandPanelTaskMode mode
	if subobjlvl != undefined do try ( subObjectLevel = subobjlvl )catch()

)

piotrglabski · 2018-05-16

I guess I've seen this script already somewhere - and I remember the same error...

It switches to Utility panel, but nothing more...

Max 2019...

---------------------------
MAXScript MacroScript Error Exception
---------------------------
-- No ""get"" function for undefined
---------------------------
OK
---------------------------

.

jahman · 2018-05-16

It was written yesterday so it's unlikely. :) But many scripts use similar approach to handle UI.
Maybe someone who have max2019 installed could help you modifying it to work.
I guess you noticed that AD changed max UI pretty heavily, and that's the main reason why some scripts can't work in new versions as expected.

piotrglabski · 2018-05-17

You were most helpful anyway, than you for your help.
I wish I had programming skills - I see how much can be easier and better in 3Dmax with MaxScript, I've try to learn so many times, but I'm litte "slow" in that matter.

(I've try your script also in 3DMax2018, same error)

Piotr

.

miauu · 2021-12-30

This works in max 2020:


(
	local mode = GetCommandPanelTaskMode()
	local subobjlvl = subObjectLevel
 
	UtilityPanel.OpenUtility Measure	
	hwnd  = (windows.getChildHWND #max "Lock Selection")[1]
	state = windows.sendMessage hwnd 0xF0 0 0 -- check if locked selection state is active
 
	if state != 1 do
	(
		windows.sendMessage hwnd 0x201 1 0
		windows.sendMessage hwnd 0x202 0 0
	)
 
	UIAccessor.PressButton (windows.getChildHWND #max "New Floater")[1]
 
        -- position Measure window at certain coord
	(dotNetClass "Autodesk.Max.GlobalInterface").Instance.SlideWindow (for w in UIAccessor.GetPopupDialogs() collect w)[1] 100 100
 
	SetCommandPanelTaskMode mode
	if subobjlvl != undefined do try ( subObjectLevel = subobjlvl )catch()
 
)

Test it in max 2019 and if the error occur - post here the full error message. Most probably the line in which the error happens will be written in it.

Open Measure Floater New Floater.

Graham3D4D · 2021-12-29

Thanks for that.
The script takes me to, and opens, the Measure Tab. But it doesn't create a New Floater.
Ideally I want to open a New (Measure) Floater and place it to a particular place on the screen.

How can I do that?

Thanks again

.

jahman · 2021-12-29

it was written for older max versions, so it doesn't work in QT interface
change it like that and it will work as expected


...
        hwnd  = (windows.getChildHWND #max "Lock Selection")[1]
	state = windows.sendMessage hwnd 0xF0 0 0 -- check if locked selection state is active

	if state != 1 do
	(
		windows.sendMessage hwnd 0x201 1 0
		windows.sendMessage hwnd 0x202 0 0
	)
	
	UIAccessor.PressButton (windows.getChildHWND #max "New Floater")[1]
	
        -- position Measure window at certain coord
	(dotNetClass "Autodesk.Max.GlobalInterface").Instance.SlideWindow (for w in UIAccessor.GetPopupDialogs() collect w)[1] 100 100
 ...