I have questions about push/pull by group

Hi I ask questions about the push/pull function by group.

I was studying the API by referring to the API created by the user ‘dezmo’, but something is not going my way.

def pushpull_faces_in_selected_groups
  prompts = ['Push/Pull Distance']
  defaults = [0.to_l]
  results = UI.inputbox prompts, defaults, 'Distance to Push/Pull'
  distance = results[0]
  model = Sketchup.active_model
  targets = model.selection.grep(Sketchup::Group)
  targets.each{ |target|
    tents = target.entities
    faces = tents.grep(Sketchup::Face)
    faces.each{ |e|
      e.pushpull distance, true

In the case of the API referred to above, push/pull proceeds in the direction, but the selected face is reversed to confirm that a group is created.
In the tool currently under development (three.js), it is classified according to direction, so the normal value of the corresponding face is also important, so the face should not be reversed.

Second, the current height value (corresponding to distance) is given a -value (because the normal value of the default face is -Zaxis)
I ask if there is any way to go up only with Zaxis.

I always feel grateful for solving the problem with friendly explanations from users.
I would appreciate any help again. :pray:

before pushpull check face.normal
in case it’s negative change de distance value

Note that with the release of 2021.1, faces are now created on the XY “ground” plane with “butter-side” up.

So, although you’re still on v2015, your extension will need to take into account these newer versions behavior.

norm_vec = face.normal
if norm_vec.parrallel?(Z_AXIS)
  face.reverse! unless norm_vec.samedirection?(Z_AXIS)


I’m trying, but it doesn’t work out as well as the advice. :joy: :joy: :joy: thanks for the advice

Thanks for helping me again but I did not understand how to apply
I boldly applied it to the extension, but the error occurs
‘Error: #<NoMethodError: undefined method `normal’ for #Array:0x0000021ccff5c858>’

Should I defin ‘normal’ in advance?

You should apply normal to a face. You are applying to an array

1 Like

Thanks for helping me

I solved my problem now

Thank you :partying_face:

Thanks for your advice :partying_face:

@evercloud36 I agree. In your code snippet, the face will be the iterative reference e inside this block …

    faces.each { |e|
      e.pushpull(distance, true)

Just to clarify: :wink:
I did not created Application Programming Interface. I created a “quick & dirty” code snippet (method) using the SketchUp Ruby API. :innocent:

1 Like

I’m just wondering what the ‘transform tool’ is and how you’re going to use it in your code?