Search ProofOfProgress Blog

Saturday, April 2, 2011

Multi-PickButton MaxScript Code



[Source Code Below] Download Source: ****HERE****



-- 1 2 3 4 5 6 7 8 9 10
--34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
--This code will demo how to use my multi-pick-button.
--Works like normal pick button, but allows you to select multiple objects.
--
-- ***************************************************************************
-- ***************************************************************************
-- Want more free scripts?: http://www.youtube.com/user/PolygonRunner ******
-- ***************************************************************************
-- ***************************************************************************

rollout MainRollout "Multi-PickButton Demo"(
local RV_ArrayNodes = #(); --Array of nodes selected by button ArrayPick

button ArrayPick "Select Objects, THEN click me.";

--The list box displays what you currently have selected by the ArrayPick button.
listbox LB01 "Influencing Objs"
height:5; --5 lines tall.
ReadOnly:True; --Read Only List.

--Control for MULTI-OBJECT PICK BUTTON
on ArrayPick Pressed do(
if selection.count == 0 then(
if(LB01.items.count==0)then(
ArrayPick.Caption = "LIST EMPTY";
)else(
ArrayPick.Caption = "List Unchanged";
)--[x]
)else(
MSTAT = #no; --Do not append;
if (LB01.items.count > 0)then(
mstatText = "";
mstatText = mstatText + "[YES]: Append to previous selection." + "\n";
mstatText = mstatText + "[NO]: Replace old selection." + "\n";
mstatText = mstatText + "[CANCEL]: Don't do anything." + "\n";
MSTAT = yesNoCancelBox mstatText \
title:"Append or Replace?" beep:False;
print(MSTAT);
)--[x]

if (MSTAT!=#cancel)then(
nodeNameArray = #();

--If #no: Create New Selection.
if(MSTAT==#no)then(
RV_ArrayNodes = #();
for i = 1 to selection.count do(
nodeNameArray[i] = selection[i].name;
RV_ArrayNodes[i] = selection[i];
)--[X]
ArrayPick.Caption = "List Populated";
LB01.items = nodeNameArray;
print("Rv array nodes===" + RV_ArrayNodes as string);
)--[#no]

--If #yes: Append to Original selection.
if(MSTAT==#yes)then(
nodeNameArray = LB01.items;
for i = 1 to selection.count do(
APN = appendIfUnique RV_ArrayNodes selection[i];
if(APN)then(append nodeNameArray selection[i].name);
)--[X]
ArrayPick.Caption = "List Appended To";
LB01.items = nodeNameArray;
print("Rv array nodes===" + RV_ArrayNodes as string);

)--[#yes]
)--[MSTAT!=#cancel]
)--[Selection.count]
)--[ArrayPick Pressed]
)--[End Rollout]
CreateDialog MainRollout;
-- 1 2 3 4 5 6 7 8 9 10
--34567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

No comments:

Post a Comment