ScriptSpot

Forum topic · General Scripting

Edit Poly vertex Collapse with Scale (Scale vertices). Thanx Miauu

By Nik · 2013-07-30

Description
Comments (10)

miauu · 2013-07-31

:)
Glad to help.
:)

Just cool!

Nik · 2013-07-31

I'm happy :) Thanx

A HUGE THANK YOU, GREAT MAN. THIS GORGEOUS

Nik · 2013-07-31

JUST WELL DONE Thank you for this work and spent time on me.

Attachments

miauu · 2013-07-31

Send me the scene with the teapot and I will find where the problem is.

I've also noticed that sometimes pressing the Collapse button in modify panel(executing the sctip code also) not collapse all verts(some of they stays in places).

.

miauu · 2013-07-31


(
	curO = modPanel.getCurrentObject()
	if classof curO == Edit_Poly do
	(
		allVertsBA = curO.GetSelection #Vertex
		if allVertsBA.numberset != 0 do
		(
			centerPos = [0,0,0]
			for v in allVertsBA do 
			(
				vPos = curO.getVertex v
				centerPos.x += vPos.x
				centerPos.y += vPos.y
				centerPos.z += vPos.z
			)
			centerPos /= allVertsBA.numberset
	 
			curO.SetOperation #Transform
			curO.ScaleSelection  [1e-005,1e-005,1e-005] parent:(transMatrix centerPos) axis:(transMatrix centerPos)
			curO.Commit ()
		)
	)
	if classof curO == Editable_Poly do
	(
		local poGetVert = polyop.getVert
		local poSetVert = polyop.setVert
		allVertsBA = polyop.getVertSelection curO
		if allVertsBA.numberset != 0 do
		(
			centerPos = [0,0,0]
			for v in allVertsBA do 
			(
				vPos = poGetVert curO v
				centerPos.x += vPos.x
				centerPos.y += vPos.y
				centerPos.z += vPos.z
			)
			centerPos /= allVertsBA.numberset
			for v in allVertsBA do
			(
				poSetVert curO v centerPos
			)
		)
	)
)

miauu · 2013-07-30

With Edit Poly modifier:


$.modifiers[1].ButtonOp #CollapseVertex
$.modifiers[1].Commit()

Or if you wants to do it with the scale:


(
	allVertsBA = $.modifiers[#Edit_Poly].GetSelection #Vertex
	centerPos = [0,0,0]
	for v in allVertsBA do 
	(
		vPos = $.modifiers[#Edit_Poly].getVertex v node:$
		centerPos.x += vPos.x
		centerPos.y += vPos.y
		centerPos.z += vPos.z
	)
	centerPos /= allVertsBA.numberset
	
	$.modifiers[#Edit_Poly].SetOperation #Transform
	$.modifiers[#Edit_Poly].ScaleSelection  [1e-005,1e-005,1e-005] parent:(transMatrix centerPos) axis:(transMatrix centerPos)
	$.modifiers[#Edit_Poly].Commit ()
)

What you mean by attached object?

Sorry does not work

Nik · 2013-07-31

with scale:

-- Unknown property: "modifiers" in $selection

Moreover, when try to repeat the code obtained from MAXscript Listener, all turns out the same way.

And

$.modifiers[1].ButtonOp #CollapseVertex
$.modifiers[1].Commit()

not working properly too.

Attachments

Oo, thanx miauu but...

Nik · 2013-07-30

But I realized that I had to do it this way

http://youtu.be/l8-1XuedY7A

For me this for the time being difficult. Please help
And even to the same how this will be with attached objects.

Thanx for response.

.

miauu · 2013-07-30

Try this:


polyop.collapseVerts $ (polyop.getVertSelection $)

Works only with editable poly objects