ScriptSpot

Forum topic · General Scripting

Manipulate current Poly_Select vertex selection

By dxmedia · 2010-09-21

Description

Hello,

I am very new at this.

I am trying to automatically edit the vertex selection of the currently selected "Poly Select" modifier (my object has many).

I need a way to read currently selected vertexes and modify the selection.

It seems I can't solve this myself.

Thanks in advance.

Comments (3)

Graph · 2010-09-22

hehe you got it
skin it like an onion, layer by layer
get vertSelection (polyOp)
skin the polySelect layer
and butter it up with an edit_poly layer

you might be new to this but you already think the right way

dxmedia · 2010-09-22

Thnaks very much,

Yes, the base is Editable Poly.
I'll give it a try.

Anyway, I'm thinking about changing all my PolySelect modifiers to EditPoly, so I have direct control, without having to collapse all my modofiers (about 60-70).

Thanks again

Graph · 2010-09-22

is the baseObject of your object an editable Poly ?

because if it isnt you cant use the polyOp or polyOps methods

heres a little function to convert the baseObject of an object to ePoly


(
	local sel = selection as array
	
	local obj = sel[1]
	
	if isValidNode obj do
	(
		if classOf obj.baseobject != Editable_Poly do
		(
			max create mode	--faster than updating the visible mod stack
			
			local mods = for i = obj.modifiers.count to 1 by -1 collect copy obj.modifiers[i]	--collect the modifiers in inverse order (copys of em)
			
			for m in obj.modifiers do deletemodifier obj m	--delete the old mods
			
			addModifier obj (EditPolyMod()) before:obj.modifiers.count	--add an ePoly mod to the stack
			
			collapseStack obj		--collapse the whole thing
			
			for m in mods do addModifier obj m		--and reApply the old mods
		)
	)
	
	
)

im sure youll find an easy way using the polyOp struct and some cheating similar to mine to tackle your problem ;)

edit: if you use it on an array of objects make sure to define the mods var as undefined at the end of every iteration, no need to play with fire right?!