View Full Version : Welding spline verts... doesn't want to work

10 October 2003, 12:40 PM
Hey there MaxScripters... I posted this on, but haven't heard anything... perhaps someone in here could help?

Struggling my way through learning MAXScript... very excited about the possibilities, but I'm banging my head on this seeming simple one and can't seem to figure it out.

I'm trying to create an effect that will slice up an object using the 'section' command, and then extrude each of the spline sections. However it appears that the section command gives verts that aren't welded completely - so the resultant extrusion doesn't cap it's end. So I'm trying to have the script weld the verts before extruding but I can't get it to go. Here's the portion of the script that I'm having problems with:

minZ = $HeightTool.min.z
maxZ = $HeightTool.max.z
LayerHeight = 10

for currentZ = minZ to maxZ by LayerHeight do
s = section pos:[0, 0, currentZ]
max views redraw
convertToSplineShape s
select s
max modify mode
--modPanel.setCurrentObject $.baseObject
subobjectLevel = 1
max select invert
splineOps.weld s
updateShape s
--addModifier splineSection (Extrude())
--splineSection.modifiers[#Extrude].amount = LayerHeight/2

run it on the included sample scene attached to this post and you'll see the problem. It appears that only the last spline is getting welded the way it should... all the other splines are getting their verts selected as they should, but the weld isn't working. Hmmmmmm... can't figure it out. Any help would be greatly appreaciated. Thanks

Testing File HERE (

10 October 2003, 12:43 PM
I tried doing a script that did exactly the same thing about a year ago. and had exactly the same problem. No one ever answered my plees for help!

10 October 2003, 01:02 PM
not to sure, but by the looks of it, the reason only the last spline gets welded is because that's the one that's selected at the moment the weld kicks in, perhaps attaching all splines together, THEN select all verts and THEN weld them solves this ?

just found out you can't attach splines using maxscript :surprised. so you're basically left with two options.
1 loop thru the splines and attach there verts or break the script up in two parts and attacht them manually together and then run the last part of the script

just for the record, i don't know to much of maxscript. Just trying to use logical reasoning.

Alex Morris
10 October 2003, 05:47 PM
Dont know whether this helps or not but here's a function that I wrote for welding editable splines and also ditching all the ones that are already closed from the routine (I was trying to get it to go faster- hence splitting up the vertices into lots of about 1500 which seems to be ok on about 1Gb RAM)

Basically it loops through all the splines in the shape, discards all the closed ones, then takes only the first and last vertices of the remaining splines within the shape into an array. This is then split into chunks of 1500 vertices (750 splines) for processing (I figured that if it missed a couple of verts it wasn't a problem since the main reason for the script was reducing system overhead from imported autocad data- loads of unwelded splines really slow max down)

Incidentally you can attach splines with maxscript - look up "addandWeld" in the help file. Another option is to just install the avgdlx50 extension which has a weldverts option with a threshold built in. The reason I didnt use this was .......doh! cant remember! hehe. The function also changed the steps value for the shape as well if you want that.

CGTalk Moderation
01 January 2006, 11:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.