sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [solved]Syntax problem with a Sketchup::Face

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 679 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • IltisI Offline
      Iltis
      last edited by Iltis

      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.

      1 Reply Last reply Reply Quote 0
      • IltisI Offline
        Iltis
        last edited by

        OK, it's a typo! entitiy instead of entity! Shame on me!

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          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...

          TIG

          1 Reply Last reply Reply Quote 0
          • IltisI Offline
            Iltis
            last edited by

            Thanks TIG! 😄

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement