Spline decimation or collapsing vertices
I've a spline, a lot in fact, imported from a dwg file, and they are composed of twin segment, each one on top of each other connected at one end. So the knots array are reversed. The line is ABCDC'B'A' like, A is a segment between two knots, A' have the same coords except it was reversed.
#(#([813529,2.07842e+006,251.674], [813538,2.07843e+006,251.44]), #([813519,2.07842e+006,251.902], [813529,2.07842e+006,251.674]), #([813510,2.07842e+006,252.079], [813519,2.07842e+006,251.902]), #([813500,2.07841e+006,252.255], [813510,2.07842e+006,252.079]), #([813510,2.07842e+006,252.079], [813500,2.07841e+006,252.255]), #([813519,2.07842e+006,251.902], [813510,2.07842e+006,252.079]), #([813529,2.07842e+006,251.674], [813519,2.07842e+006,251.902]), #([813538,2.07843e+006,251.44], [813529,2.07842e+006,251.674]))
The first and last segment have the same coord, but reversed. I want to eliminate the double ones.
-- empty Array theArray = #() -- on each Spline's segment for s = 1 to (numSplines $) do ( knt = #() for k = 1 to (numKnots $ s) do ( -- Find the point coord as a point3 point = getKnotPoint $ s k append knt point )--end k loop append theArray knt )--end s loopprint a_effacer print theArray.count --Function to compare the content of two arrays fn compareSubArrays first second = ( result = true --init. return value to true if first.count != second.count then --if the count of the two subarrays is different, result = false --return false else --otherwise for i = 1 to first.count do --go through all elements in the arrays if first[i] != second[i] do result = false --and see if two elements are different result --return the result - true if identical, false if not ) for i = 1 to theArray.count do --go through all elements of the main array for j = theArray.count to i+1 by -1 do --go backwards from the last to the current+1 if compareSubArrays theArray[i] theArray[j] do deleteItem theArray j --if identical, delete the one with the higher index format "%\n" theArray --print the result to the Listener
I've tried to check each numSplines, and check the numKnots
I want to find a way to script the elimination of the CBA segment which is on top of the ABCD segment I'd like to keep. If I break the spline, and weld it.
Perhaps there's already a fonction to do that in max.
Any help apreciated, if you understand the problem :.)