Wednesday, November 29, 2023
Home3D ModelingI've questions on push/pull by group - Ruby API

I’ve questions on push/pull by group – Ruby API

Hello I ask questions in regards to the push/pull perform by group.

I used to be learning the API by referring to the API created by the person ‘dezmo’, however one thing is just not going my manner.

def pushpull_faces_in_selected_groups
  prompts = ['Push/Pull Distance']
  defaults = [0.to_l]
  outcomes = UI.inputbox prompts, defaults, 'Distance to Push/Pull'
  distance = outcomes[0]
  mannequin = Sketchup.active_model
  targets = mannequin.choice.grep(Sketchup::Group)
    tents = goal.entities
    faces = tents.grep(Sketchup::Face)

Within the case of the API referred to above, push/pull proceeds within the path, however the chosen face is reversed to substantiate {that a} group is created.
Within the instrument presently beneath growth (three.js), it’s labeled in accordance with path, so the traditional worth of the corresponding face can be necessary, so the face shouldn’t be reversed.

Second, the present top worth (akin to distance) is given a -value (as a result of the traditional worth of the default face is -Zaxis)
I ask if there’s any method to go up solely with Zaxis.

I all the time really feel grateful for fixing the issue with pleasant explanations from customers.
I might admire any assist once more. :pray:

earlier than pushpull verify face.regular
in case it’s destructive change de distance worth

Be aware that with the discharge of 2021.1, faces are actually created on the XY “floor” airplane with “butter-side” up.

So, though you’re nonetheless on v2015, your extension might want to have in mind these newer variations habits.

norm_vec = face.regular
if norm_vec.parrallel?(Z_AXIS)
  face.reverse! until norm_vec.samedirection?(Z_AXIS)


I’m making an attempt, nevertheless it doesn’t work out in addition to the recommendation. :joy: :joy: :joy: thanks for the recommendation

Thanks for serving to me once more however I didn’t perceive the best way to apply
I boldly utilized it to the extension, however the error happens
‘Error: #<NoMethodError: undefined technique `regular’ for #Array:0x0000021ccff5c858>’

Ought to I defin ‘regular’ upfront?

It is best to apply regular to a face. You’re making use of to an array

1 Like

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

    faces.every e

Simply to make clear: :wink:
I didn’t created Utility Programming Interface. I created a “fast & soiled” code snippet (technique) utilizing the SketchUp Ruby API. :innocent:

I’m simply questioning what the ‘remodel instrument’ is and the way you’re going to make use of it in your code?



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments