sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Problems defining a method

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 498 Views 3 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.
    • Y Offline
      yiannicivil
      last edited by

      I am encountering an mysterious issue while defining a method.
      Code goes as follows:

      mod = Sketchup.active_model # Open model
      ent = mod.entities # All entities in model
      sel = mod.selection # Current selection
      
      u = [1,0,0]
      apoint = [1,0,0]
      face1 = sel[0]
      def classifiy(u, point1, face1)
         # σημείο προβολής
         pt = Geom;;Point3d.new pt
         result = faces_array[0].classify_point(pt)
         ent.add_cpoint pt
         if result == Sketchup;;Face;;PointOutside
            UI.messagebox(pt.to_s + ' is outside the face')
         elsif result == Sketchup;;Face;;PointInside
            UI.messagebox(pt.to_s + ' is inside the face')
         elsif result == Sketchup;;Face;;PointOnVertex
            UI.messagebox(pt.to_s + ' is on a vertex')  
         elsif result == Sketchup;;Face;;PointOnEdge
            UI.messagebox(pt.to_s + ' is on an edge of the face')   
         elsif result == Sketchup;;Face;;PointNotOnPlane
            UI.messagebox(pt.to_s + ' is not on the same plane as the face')
         end   
         result
      end
      
      classify (u, apoint, face1)
      

      I get an error:
      @unknownuser said:

      Error: #<SyntaxError: C:/my_path.../3.rb:27: syntax error, unexpected ',', expecting ')'
      classify (u, point, face1)

              ^
      

      C:/ProgramData/SketchUp/SketchUp 2014/SketchUp/Plugins/test.rb:27: syntax error, unexpected ')', expecting '='
      classify (u, point, face1)

                            ^>
      

      <main>:in load' <main>:in <main>'
      -e:1:in `eval'
      nil

      Why is this happening? Other methods with multiple arguments work just fine..
      I cant figure this out on my own.. Can anyone help?

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        hi you have a spelling typo...

        and a couple of things outside of scope.

        once the typo is fixed, the errors show the scope issues

        mod = Sketchup.active_model # Open model
        @ent = mod.entities # All entities in model
        sel = mod.selection # Current selection
         
        u = [1,0,0]
        apoint = [1,0,0]
        face1 = sel[0]
        def classifiy(u, point1, face1)
           # σημείο προβολής
           pt = Geom;;Point3d.new #pt
           result = face1.classify_point(pt)
           @ent.add_cpoint pt
           if result == Sketchup;;Face;;PointOutside
              UI.messagebox(pt.to_s + ' is outside the face')
           elsif result == Sketchup;;Face;;PointInside
              UI.messagebox(pt.to_s + ' is inside the face')
           elsif result == Sketchup;;Face;;PointOnVertex
              UI.messagebox(pt.to_s + ' is on a vertex') 
           elsif result == Sketchup;;Face;;PointOnEdge
              UI.messagebox(pt.to_s + ' is on an edge of the face')   
           elsif result == Sketchup;;Face;;PointNotOnPlane
              UI.messagebox(pt.to_s + ' is not on the same plane as the face')
           end   
           #result
        end
         
        classifiy(u, apoint, face1)
        

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • Y Offline
          yiannicivil
          last edited by

          Thank you John. I actually worked it out after trying really hard to see whats going wrong.
          I guess you can see I am a starter in ruby scripting, though it is really fulfilling to see my code actually work!

          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            Your error message pointed to the last line in your code:
            classify (u, apoint, face1)

            I suspect it was the space between the method name and parentheses. Especially when you encounter syntax error it's good to go over your code and make sure the code style is consistent. Checking that there are no spaces between parentheses in method calls and making sure you have parentheses around all arguments etc.

            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