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

    Math functions and SU7

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 438 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.
    • B Offline
      BillW
      last edited by

      I just noticed while testing some of my SU6 plugins that there is a problem with the inbuilt Ruby Math functions. If I type the following into the Ruby console I get an error:

      tan(20)
      Error: #<NoMethodError: (eval):56: undefined method `tan' for main:Object>
      (eval):56
      Math::tan(20)
      2.23716094422474

      tan(20) works with SU6

      Can someone confirn this

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Hi Bill,

        This isn't unexpected behavior. tan is a method of the Math module, and you need to prefix it with the module name in order to call it. If you type in the Ruby Console:

        
        include Math
        
        

        then simply writing tan(20) will work. To ensure you are using Math::tan, and not someone else's 'tan' method, you probably want to always write it as 'Math::tan'

        Here is a chapter which discusses modules as namespaces:

        http://www.rubycentral.com/pickaxe/tut_modules.html

        It could be that there is a plugin in your version 6 folder that uses 'include Math' and so 'tan' is available in your version 6 Ruby Console.

        Hi

        1 Reply Last reply Reply Quote 0
        • M Offline
          MarcioAB
          last edited by

          Without "include Math" statement (directly from Ruby's console or from any autoloaded plugin), it does not work here. With "Math included", it works fine.

          Marcio

          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