Message 1 of 4
Problem with attach loop
Not applicable
12-10-2012
07:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I'm really new to maxscript, and I'm assuming this'll be super easy for someone to figure out. I have a function that goes through a multidimensional array of polys looking for objects with the same name tag (in index ), then it attaches them, stores the position in a new array, then goes through that array and deletes the elements from the original array. This process continues until there are no more elements in the original array.
I keep getting an error on the final for loop, when trying to remove the original array elements.
Error is:
-- Error occurred in z loop; filename: C:\---.ms; position: 1532; line: 48
-- Frame:
-- z: 316
-- called in anonymous codeblock; filename: C:\---.ms; position: 1571; line: 48
-- Frame:
-- holdingArray: #(2, 3, 4, 5, 6, 7, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, ...)
-- x: 359
-- Runtime error: array index must be positive number, got: 0
Code:
I keep getting an error on the final for loop, when trying to remove the original array elements.
Error is:
-- Error occurred in z loop; filename: C:\---.ms; position: 1532; line: 48
-- Frame:
-- z: 316
-- called in anonymous codeblock; filename: C:\---.ms; position: 1571; line: 48
-- Frame:
-- holdingArray: #(2, 3, 4, 5, 6, 7, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, ...)
-- x: 359
-- Runtime error: array index must be positive number, got: 0
Code:
while ThreeArray.count >1 do
(
holdingArray = #()
x=2
while x <= ThreeArray.count do
(
if ThreeArray== ThreeArray then
(
Polyop.attach (ThreeArray) (ThreeArray)
append holdingArray (x)
print ThreeArray
)
x += 1
)
sort holdingArray
print holdingarray
print "Done with Array!"
for z in holdingArray do deleteitem ThreeArray (holdingArray)
deleteitem ThreeArray 1
)