Notifications
Clear all
[Closed] Flaky addAndWeld
Jan 04, 2007 5:32 pm
I have a script that takes a bunch of little splines and adds them to a new and larger spline shape. I use addAndWeld to add the individual splines to the larger shape. However, sometimes it works as expected and sometimes verts which are right on top of eachother do not get welded (most of the time it works correctly).
Does anyone know what could be causing this? Is this a known issue/bug in max? I have experimented with various weld thresholds (very large, very small, etc.) and it seems to make virtually no difference.
2 Replies
Jan 04, 2007 5:32 pm
you should post your script so it would be easy for the scripting guru to see whats wrong.
Jan 04, 2007 5:32 pm
Here’s the function that does the adding and welding.
-- fn smartSplineAdd
-- Params: cID = integer chunk index
-- &addToMe = array of shapes to add splines to
-- &addMe = spline to add to shape
-- Return: NONE
-- Adds splines of each type preserving layer attributes.
fn smartSplineAdd cID &addToMe &addMe =
(
-- check for deleted addMe
if NOT(isValidNode addMe) then (return undefined)
-- very bells
local newEdge
local shapeBuff, segBuff
local x = addToMe.count
local noMatch = true
-- loop through existing splines in shape
while (x > 0) do (
-- get user prop buffers
try (
shapeBuff = getUserPropBuffer addToMe[x]
segBuff = getUserPropBuffer addMe
) catch (
-- decrement and skip
x -= 1
continue
)
-- compare buffers
if ((stricmp shapeBuff segBuff) == 0) then (
-- add to an existing shape
addAndWeld addToMe[x] addMe 0.1
updateShape addToMe[x]
-- mark a match and bail
noMatch = false
break
) else (
-- no matches
noMatch = true
)
-- decrement x
x -= 1
)
-- no splines with those properties?
if (noMatch OR x == 0) then (
-- get segment properties
try (segBuff = getUserPropBuffer addMe) catch (return undefined)
-- create a new shape
newEdge = convertToSplineShape (copy gChunkBoundArr[cID])
-- set its properties
setUserPropBuffer newEdge segBuff
-- add the segment
addAndWeld newEdge addMe 0.1
updateShape newEdge
-- add new splineShape to the array
append addToMe newEdge
)
)