Function to grow directionally


Hi everybody.

I’m working for script that allow to manipulate easy skin vertex weight after weights are baked in skin as max skinning tools was updated long time a go. As far I doing well but I need function that will make grow vertex selection directionally.
Unlike skinOps.growSelection skin which make selection grow in both directions i will rather want to have two functions; - grow up and grow down - also shrink up/down. It would be easy if vertex order would be 1,2,3,4 etc but usually is 1,2,8,9 etc Do anybody has any idea how and is it possible to achieve that by maxscript ?


in general, the idea is quite simple…

you must first find the bounding box of current skin vertex selection, and then make a standard grow…
after that deselect all that goes beyond the bounding box in a certain direction…

this can be done automatically by monitoring skin selection changes, for example using when construct


Thank you, I don`t know if this idea may work a little slow when mix with my code but more less I grasp your idea however - " deselect all that goes beyond the bounding box in a certain direction" - this is the part which I have no idea how to conclude which are verticles are outside bindingbox and how to specify direction. So your idea is something like this ?:

fn vertsBindingBox=
if selection.count == 1 and classof currentmodeskin == skin do
	theObj = $
	theVerts = skinOps.getSelectedVertices (modPanel.getCurrentObject()) -- as array

		xVals = #()
	yVals = #()
	zVals = #()

	for v in theVerts do
		vertPos =  polyop.getvert theObj v
		append xVals vertPos.x
		append yVals vertPos.y
		append zVals vertPos.z
	theWidth = (amax xVals) - (amin xVals)
	theLength = (amax yVals) - (amin yVals)
	theHeight = (amax zVals) - (amin zVals)
	-- I dont know if this part is necesery 
	--avgPos = [(((amax xVals) + (amin xVals)) / 2.),(((amax yVals) + (amin yVals)) / 2.),(((amax zVals) + (amin zVals)) / 2.)]
	return [theLength, theWidth,theHeight];

        for o=1 to 15 do (skinOps.growSelection (modPanel.getCurrentObject()))


here is how I could get bbox :

fn getSkinVertSelectionBBox sk: node: = 
	if sk == unsupplied do sk = modpanel.getcurrentobject()
	if iskindof sk skin do
		if node == unsupplied do node = selection[1]
		vv = skinOps.getselectedvertices sk 
		center = [0,0,0]
		pp = for v in vv collect 
			p = polyop.getvert node v
			center += p
		center /= vv.count
		bb = box3 center center
		expandtoinclude bb pp

		--dummy boxsize:(b.max - b.min)

fn growSkinSelectionUp sk: node: =
	if sk == unsupplied do sk = modpanel.getcurrentobject()
	if iskindof sk skin do
		if node == unsupplied do node = selection[1]
		bb = getSkinVertSelectionBBox sk:sk node:node
		skinops.growselection sk
		ss = skinOps.getselectedvertices sk 
		ss = for v in ss collect
			p = polyop.getvert node v 
			if contains bb p or (p.z >= bb.max.z) then v else dontcollect 
		skinops.selectvertices sk ss


Another way is to do the growing/shrinking yourself.
You can find all neighbors for selected vertices. They are “growth candidates”… but we can only filter out those that are in a certain direction from the target vertex. If at least one target vertex causes a neighbor to grow in the specified direction, then this neighbor is included in the selection list.

This method looks much more promising… I would definitely go in that direction.


I think second solution is way to go because the one with bindingboxes require quit a lot of extra calculations but how to know which vertex is “next to selected” I assume the only way is to check selected vertex against all existing but how to get direction, I made quickly snipped just to check if I can check sorrounding vertex anyhow - that should only grow(but wont work dont know why) and starting from one selected vertex for for the sake of simplicity but how to get direction?


oryginalselection=(skinOps.getSelectedVertices currentmodeskin)
curentselection=skinOps.SelectVertices currentmodeskin #{1…($.numVerts)}
allverts=(skinOps.getSelectedVertices currentmodeskin)
skinOps.SelectVertices currentmodeskin oryginalselection

for o in allverts do
v1 = $.verts[o].pos
v2 = $.verts[oryginalselection[1]].pos -- first selected vertex 
a = distance v1 v2
if a < tolerance then (append Vertsarray o;exit) -- still not growing and no direction

skinOps.SelectVertices currentmodeskin Vertsarray