ScriptSpot

Forum topic · Scripts Wanted

need help please...

By titane357 · 2011-05-13

Description

Hello
I need a script to move up selected polys with step(to make stairs)
Best should be to move selected elements with a UI to give the value... (stairs can have multiples polys)
Sorry, but I need this, and I can't do it myself, if somebody can help ? :-) Thanks

Comments (6)

BitArray.NumberSet

Anubis · 2011-05-14

Hi Titane,
shortly getFaceSelection() return BitArray.
I think this example will explain what you need:

b = ConvertTo (Box()) Editable_Poly
polyop.setFaceSelection b #(2) -- select 'top' face
fSel = polyop.getFaceSelection b -- #{2}
fSel.count -- 6
classOf fSel -- BitArray
fSel.numberSet -- 1

Cheers!

titane357 · 2011-05-14

Hello !
Perhaps not very elegant, but it works... I don't know how to use bitarray, so I convert to array...

Thanks ! :-)

-----
h=0
poly = selection[1]
fSel = polyop.getFaceSelection poly
classOf fSel -- BitArray
fSelA = fSel as array
for a=1 to fSel.numberSet do
(
h+=10
print fSel.numberSet
vList = polyop.getVertsUsingFace poly fSelA[a]
polyop.moveVert poly vList [0,0,h]
)
update poly
---

titane357 · 2011-05-14

problem is : the selection order is not conserved....

so, the job done :)

Anubis · 2011-05-15

Working with BitArrays is more faster than Arrays,
but use what you like and found as easy ;)

h = 0 ; poly = selection[1]
fSel = polyop.getFaceSelection poly
for bit in fSel do
(
	h+=10
	vList = polyop.getVertsUsingFace poly bit
	polyop.moveVert poly vList [0,0,h]
)
update poly

Example

Anubis · 2011-05-13

-- move/offset selected faces +3 by Z
poly = selection[1]
if isKindOf $ Editable_Poly do
(
	fSel = polyop.getFaceSelection poly
	vList = polyop.getVertsUsingFace poly fSel
	polyop.moveVert poly vList [0,0,3]
	update poly
)

Cheers!

titane357 · 2011-05-14

Hello Anubis !
Thanks for help but I don't understand something.
I need to make a loop to move up each face with an incremental value.
Can I tape : "fSel.count" ? because fSel.count give me total faces, not just selected faces.
I know that I'm a poor scripter but I don't understand what is wrong with the following...

h=0
poly = selection[1]
fSel = polyop.getFaceSelection poly
for a=1 to fSel.count do
(
h+=1
vList = polyop.getVertsUsingFace poly fSel[a]
polyop.moveVert poly vList [0,0,h]
)
update poly