I want to add a new object only if its not already in the list. I don't want duplicate names of the same object.
This is what I have so far but I'm not sure what I'm missing? Why wont it work.
(
try(DestroyDialog rlDitto)catch()
local AnimObjs = #()
rollout rlD ""
(
MultiListBox mlbxAnimatedObjects "Animated Objects" pos:[10,7] width:120 height:12
button btnAddAnimObj "+" pos:[10,185] width:24 height:24
on btnAddAnimObj pressed do
(
userSel = getCurrentSelection()
if userSel.count >= 1 do
(
for o in userSel do
(
for i=1 to mlbxAnimatedObjects.items.count do
(
currListObj = (getNodeByName mlbxAnimatedObjects.items[i])
if (currListObj.name != o.name) do
(
append mlbxAnimatedObjects.items o.name
mlbxAnimatedObjects.items = mlbxAnimatedObjects.items
append AnimObjs o
)
)
)
)
print AnimObjs
)
)
createDialog rlD
)
By
Comments (5)
Comment policy
What will happend if you have 2 different objects with the same name?
For example(stupid example I think):
Hand_01 - editable poly
Hand_01 - standart primitive
I suggest you to use GetHandleByAnim/ GetAnimByHandle or handle/maxOps.getNodeByHandle to collect the objects. :)
You don't have to specify the object name.
It will add it if the object is unique whether the name is the name or not.
Thanks guys for the help. I was unaware of the Append if unique. Thanks you very much.
Hey John,
look for
in the help file, guess that could work for you
Cheers
You can use the command findItem
myArray = #("array1", "array2", "array3")
x = findItem myArray.items searchObj.name
if (searchObj != undefined and x == 0) do
(
myArray .items = append myArray .items (searchObj.name as string)
) else (
messageBox "Sorry, this item is already in the list"
)