[solved]Syntax problem with a Sketchup::Face
-
Hello,
Could you tell me what's wrong in this code?

(Z is a parameter. If z=0, I want only the faces in the Z=0 plane)selection.each do |entity| if entity.is_a?(Sketchup;;Face) if z == 1 || (z == 0 && entity.normal.x.abs < 0.00001 && entitiy.normal.y.abs < 0.00001 && entity.vertices[0].z.abs < 0.000001 ) # Sketchup tolerance ; 0.0001 inch) ........In the Ruby console :
Error: #<NameError: undefined local variable or method `entitiy'Thank you for your help.
BR,
Renaud. -
OK, it's a typo! entitiy instead of entity! Shame on me!
-
A common thing !
I often do it.You could simplify your code thus:
selection.grep(Sketchup;;Face).each{|face| if face.normal.parallel?(Z_AXIS) ###... end }This collects all selected faces and if they are 'flat' you do something...
The parallel? check has built-in tolerance... -
Thanks TIG!

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement