# Face pushpull goes in different directions

Sometimes when I run the following code, it creates a box that is pushpulled up. Other times, the same values produce a box that pushpulled down. It may be other things I am doing in code elsewhere. But I have no idea. Can anyone explain why the same code with the save values would sometimes produce different results?

``````def CreateBoxGroup(height, length, width, x, y, z)
#Footprint
pts1 = []
pts1[0] = [x,y,z]
pts1[1] = [x + length, y, z]
pts1[2] = [x + length, y + width, z]
pts1[3] = [x, y + width, z]

face.pushpull(height,true)

return group
end``````

The orientation of a new face is magically flipped if it is drawn on the ground plane, so that the back side faces upward. That will cause it to extrude in the opposite direction to faces placed at other z.

2 Likes

The PushPull goes in the direction of the face.normal
So if the face is facing down it extrudes up.
If it faces up it extrudes down.

Unfortunately you canât always be sure which way the face is orientatedâŚ
Typically a loop of vertex points makes a face oriented positively when its winding is ccw.
But if the face is flat on the ground at z=0, then no matter what the âwindingâ of its vertex points is it always faces downwards !

So itâs best to check the vertex points âwindingâ direction, and the faceâs flat z level [correcting as necessary using face.reverse etc]

Otherwise check the face.normal and use that to determine the PushPull value as + or -ve to suitâŚ

âopposite directionâ ?

1 Like

Yes - the PushPull extrusion goes contrary to the direction of the face.normal, would be a more accurate phrasingâŚ
But of course when you try it out itâll be obvious !!

I think that will do the trick. Once I create my face (always flat) I will check the .normal z value and adjust accordingly.

Thanks everyone for the quick answer!

1 Like

Iâd recommend always checking the normal direction and reverse the face if needed.

``````def create_box_group(height, length, width, x, y, z)
points = [
[x, y, z],
[x + length, y, z],
[x + length, y + width, z],
[x, y + width, z]
]