Move selected polys in order

Hi,
I wanted to make stairs more easy to do.
I usually draw the stair on top view with one editable poly.
Then I select polys and move up or down one by one...
It is nice because it works on all type of stairs I need.
What I want to do is select polys in order ( paintselect ) and run script to move first poly 10cm up, second poly 20cm up,....

Anybody can help ? Thanks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

Try this:

(
	global rol_movePolys
	try(destroyDialog rol_movePolys)catch()
	rollout rol_movePolys "Move Polygons"
	(
		local curO = undefined
		local firstPolyBA = #{}
		local allStairsFacesBA = #{}
 
		local poGetVertsUsingFace = polyop.getVertsUsingFace
		local poGetFaceCenter = polyop.getFaceCenter
		local poGetFaceSelection = polyop.getFaceSelection
		local poMoveVert = polyop.moveVert
 
		button btn_getFirstFace "Get first face" width:140
		button btn_getAllOtherfaces "Get all faces" width:140
		spinner spn_moveVal "" range:[10,1e9,10] type:#worldUnits
		button btn_moveFaces "Move faces" width:140
 
		function SortByXMember arr1 arr2 x:1 =
		(
			case of
			(
				(arr1[x] < arr2[x]):-1
				(arr1[x] > arr2[x]):1
				default:0
			)
		)
 
		on btn_getFirstFace pressed do
		(
			if selection.count == 1 and classOf selection[1] == Editable_Poly and subobjectlevel == 4 do
			(
				curO = selection[1]
				if (firstPolyBA = poGetFaceSelection curO).numberset == 1 then
				(
 
				)
				else
				(
					messagebox "Select only one polugon" title:""
				)
			)
		)
 
		on btn_getAllOtherfaces pressed do
		(
			if (allStairsFacesBA = poGetFaceSelection curO).numberset != 0 then
			(
				allStairsFacesBA -= firstPolyBA
			)
			else
			(
				messagebox "Select stair's faces" title:""
			)
		)
 
		on btn_moveFaces pressed do
		(
			if not firstPolyBA.isEmpty and not allStairsFacesBA.isEmpty do
			(
				stairFacesArr = #()
				zeroPos = poGetFaceCenter curO (firstPolyBA as array)[1]
				for f in allStairsFacesBA do
				(
					fPos = poGetFaceCenter curO f
 
					append stairFacesArr #((distance fPos zeroPos), poGetVertsUsingFace curO f)
				)
 
				qsort stairFacesArr SortByXMember x:1
 
				zOffset = spn_moveVal.value
				for i = 1 to stairFacesArr.count do
				(
					poMoveVert curO stairFacesArr[i][2] [0,0,(zOffset * i)]
				)
			)
		)
 
	)
	createdialog rol_movePolys 	
)

Select the first face of the stairs and press the "Get first face" button. Then select all other faces(the first face also can be selected) and press the "Get all faces" button. Set the value of the spinner and press the "Move faces" button.

titane357's picture

o_O Hi Miauu ! Not only this

o_O
Hi Miauu !
Not only this script works like a charm, but it is what exactly I needed !!!!
I hope you had this is a secret place, you don't make it specially !
As always, I don't undestand the code.
My contribution is a spelling correction ( the only thing I can do ):
"messagebox "Select only one polugon" title:"" ----> polYgon
Thank you very much ! You're the king !
Take Care ! :-)

miauu's picture

.

Thank you. :)
My English is awful so... :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.