Notifications
Clear all

[Closed] "findItem" not work

ResultP = #(#(10,20,20),#(10,20,20),#(10,20,10))
TakeR = #(#())
for k=1 to 3 do TakeR[1][k] = ResultP[1][k]
print (findItem ResultPluta PereborSt[1]) –here always 0

why “findItem” don’t work with array ResultP?

how to do it?

4 Replies

As you can see in the reference “finditem does a MAXScript ‘==’ comparison between elements in the array and the target object” and you can’t compare two arrays that way, if you want to do this you have to create your own functinon to emulate the finditem when the searched item is another array. Here is an example:

fn findArrayInArray array2d array1d =
(
for i=1 to array2d.Count do
(
a=array2d[i]
if a.count == array1d.count then
(
equals = true
for j=1 to a.count do if a[j] != array1d[j] then equals = false
if equals then return i
)
)
return 0
)

aa = #(#(10,20,20),#(10,20,20),#(10,20,10))
idx = findArrayInArray aa #(10,20,10)
print idx

/Lui

 PEN

There has already been a whole thread on this subject that can’t be to far down the list now. Do a search for it as there were several options given.

thank you Lui for script.

how I can create my own class? please show me some example

your script work very good. big thanks