Notifications
Clear all

[Closed] Move faces and object

I’m trying to make a script to move faces of polygons by a certain vlaue on the z-axis.
Specifically ,I want to move each selection face by increased the value of 50mm.

Please,see the picture A. That’s result of the ideal.


selobj=$selection as array
selFaces=polyop.getFaceSelection selobj[1]
IncrementNum=50

n=1
for i in selFaces do
(
move i [0,0,IncrementNum*n]
n+=1
)

On the other hand,
I has tried to move a few object,not faces, by another script.


selobjBox=$selection as array
IncrementNum=50

n=1
for i in selobjBox do
(
move i [0,0,IncrementNum*n]
n+=1
)

It’s worked,but It was not the result I had expected.
Please,see the picture B. I wanted to arrange progrresively.

Please, help me. I’m confused.
Sorry my poor English,Thank you.

8 Replies

This is for moving faces:

(
	if selection.count == 1 do
	(
		selObj = selection[1]
		if classOf selObj == Editable_Poly do
		(
			selFacesBA = polyop.getFaceSelection selObj
			incrementNum = 50
			n = 0
			for f in selFacesBA do
			(
				vertsBA = polyop.getVertsUsingFace selObj f
				polyop.moveVert selObj vertsBA [0,0,IncrementNum*n]
				n += 1
			)
		)
	)
)

Moving objects not works, because the objects have to be selected properly or sorted properly.
Select boxes(from your example) one by one starting from the box you want to be first moved and then use your script:

(
	selobjBox= selection as array
	IncrementNum=50
	n=1
	for i in selobjBox do
	(
		move i [0,0,IncrementNum*n]
		n+=1
	)
)

If you select objects not in order(all objects at once with lmb click and drag for example) you will get the result you already have.

Thank you so much as always.Sorry for the late reply.

I understand allittle bit. “polyop.getFaceSelection”method returns as bitarray,not number array.
So,I get a few new questions.
I have got selected faces of polygon ,
but in this next line you use polyop getVert method and moveVert method.
Why do you replace faces with verts ?
Could you keep faces of polygon selected and move faces?
I can’t find out polyop moveface method in the help files.

So thanks for your patience.

I move verts because there is no command that move faces. There is a move command, but it works with selection of objects, verts, faces, which slows down the script(you have to select the object, to select the faces and then to execute the move command.). If you have to use this in a loop all process of selecting will slow down the script. The proper way is to convert the selected faces(or edges) to vertices and then to use the polyop.setVert(or approriate editable mesh/edit poly modifier command) to move those verts. This way there is no need the obejct to be selected, the faces/edges/verts to be selected and so on. Converting the faces/edges to verts will nto brake your current selection of faces/edges or the current selection of verts(if you do the conversion properly).

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

outline

Hi, Denis and Heppy New Year.

Outline not move faces in the way he wants or I will learn something new.

if we work with a single face it is much faster to use polyop.getfaceverts. the polyop.getvertsusingface might be many times slower than polyop.getfaceverts, depending on number of faces in object

Thank you.
Now the OP can choose what to use.

Happy New Year !
Thank you so much for the detailed explanation on move command.
I ’ve never thought about time delay of script.
I ’ll be able to think about the OP from different angles.
thank you,miauu and denisT.