ScriptSpot

Forum topic · General Scripting

Maxscript: Get currently selected operand objects of a boolean3 object?

By OccultArt · 2020-02-09

Description

Does anyone know if it is possible to get the currently selected operand objects (From the list box) for a boolean3 object within Maxscript? I know that you can change the properties of operands based on their index. But I want to change the properties of operands selected in the Listbox by the user.

Attachments
Comments (1)

Swordslayer · 2020-02-09

(
	local LB_GETSEL = 0x187
	local LB_GETCOUNT = 0x18B
	local iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance

	fn getListBoxItemCount hWnd =
		windows.sendMessage hWnd LB_GETCOUNT 0 0

	fn isListBoxItemSelected hWnd index =
		windows.sendMessage hWnd LB_GETSEL index 0 > 0
	
	local obj = modPanel.getCurrentObject()
	if isKindOf obj Boolean3 do
	(
		local cpHWnd = iGlobal.UtilGetCoreInterface.CommandPanelRollup.HWnd
		local cpChildren = windows.getChildrenHWnd cpHWnd
		local listBoxHWnd = for child in cpChildren
			where UIAccessor.getWindowResourceID child[1] == 1020 do
				exit with child[1]

		if isKindOf listBoxHWnd Number do
		(
			local opName, itemCount = getListBoxItemCount listBoxHWnd

			local selectedItems = for i = 0 to itemCount - 1
				where isListBoxItemSelected listBoxHWnd i collect
					(obj.GetOperandName (i+1) &opName; opName)
		)
	)
)