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

    How do I get Mathn.rb to work?

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 5 Posters 716 Views 5 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.
    • J Offline
      Jim
      last edited by

      The StdLib is here:

      C:\Program Files (x86)\SketchUp\SketchUp 2014\Tools\RubyStdLib

      I thought Mathn was left out for being incompatible, or drastically changing the way mathematics are represented in Ruby?

      Hi

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

        I see, you are using SketchUp 13. Version 13 uses a very old and and obsolete version of Ruby and does not have any of the standard library files available.

        Why do you need from mathn?

        Hi

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

          @jim
          if I restart SU and try this without the require 'mathn'...

          > Math.sqrt(- 4/9)  
          Error; #<Math;;DomainError; Numerical argument is out of domain - "sqrt">
          <main>;in `sqrt'
          <main>;in `<main>'
          -e;1;in `eval'
          nil
          

          so, it appears to be functional on mac at least...

          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
          • J Offline
            Jim
            last edited by

            But how many plugins count on the Math module not changing behavior?

            Hi

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

              I think we saw some plugins failing because of how "mathn" modified the base classes. But it was not one of the removed libs. We removed only what caused crashes.

              While we didn't remove the lib, we kind of hoped no one would use it, as it will break some plugins. I think I made changes to a couple of my plugins to account for the possibility of mathn.

              One example of what happens with mathn.
              ` n = 2 / 3
              0

              require "mathn"
              true

              m = 2 / 3
              (2/3)

              n.class
              Fixnum

              m.class
              Rational`

              1 Reply Last reply Reply Quote 0
              • E Offline
                Ellipser
                last edited by

                Thanks. I'm going to upgrade to 2014. I'm using it for its complex numbers functions. That spirograph plugin I made crashes the system with relatively simple designs, and I am going to re-do it using complex numbers with the hope that it uses less system resources and averts a crash.

                I'll post the plugin when I'm done with it.

                Thanks for all the info too. Some of those questions were just wondering out loud.

                When I really get good at Sketchup Ruby, I'll be able to make all the designs in the little booklet that comes with the kit. It's some really cool symmetry I think.


                Sprirograph in 4 way.jpg

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

                  @ellipser said:

                  Thanks. I'm going to upgrade to 2014. I'm using it for its complex numbers functions. That spirograph plugin I made crashes the system with relatively simple designs, and I am going to re-do it using complex numbers with the hope that it uses less system resources and averts a crash.

                  Right, I doubt you crash for the reasons you think. If that's your motivation to use it then I don't really think it'll pay off.
                  When you crash, you get a BugSplat dialog, right? Did you submit these? Did you enter any info in them that we can look up? We might be able to help you pin-point the source of your crash and find a workaround with less guessing.

                  1 Reply Last reply Reply Quote 0
                  • E Offline
                    Ellipser
                    last edited by

                    @tt_su said:

                    @ellipser said:

                    Thanks. I'm going to upgrade to 2014. I'm using it for its complex numbers functions. That spirograph plugin I made crashes the system with relatively simple designs, and I am going to re-do it using complex numbers with the hope that it uses less system resources and averts a crash.

                    Right, I doubt you crash for the reasons you think. If that's your motivation to use it then I don't really think it'll pay off.
                    When you crash, you get a BugSplat dialog, right? Did you submit these? Did you enter any info in them that we can look up? We might be able to help you pin-point the source of your crash and find a workaround with less guessing.

                    I guess I'm not using the right terminology. It really doesn't crash, it just takes a long time to process, so long that I resort to a ctrl-alt-delete after about 5 minutes of waiting. I guess part of this is that I'm using a slow computer. Sometimes when I use that plugin, it says, "Sketchup is not responding" but if I wait long enough, it eventually completes the process.

                    So, really there is no crash, just that I'm using a slow computer. I never really thought that a crash is different than a process that takes too long and you get a Microsoft-level error message.

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

                      Are you just doing computations? Or are you generating geometry?
                      For computations adding more Ruby code (ie another Ruby library) won't speed things up. I've had to resort to writing Ruby C Extensions to do calculations fast. For just doing math C/C++ isn't that scary. We got examples of projects in Visual Studio and Xcode on GitHub that have everything set up to toy around.
                      If it's generating geometry there might be ways to get better performance - bulk operations etc.

                      Do you have some code to look at - that way we would know exactly what we're dealing with here?

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        @tt_su said:

                        I think we saw some plugins failing because of how "mathn" modified the base classes. But it was not one of the removed libs. We removed only what caused crashes.

                        While we didn't remove the lib mathn.rb, we kind of hoped no one would use it, as it will break some plugins.

                        With Ruby 2.x, developers can now use refinements for explicit files.
                        Using this lib should be OK within a refined file.

                        ADD: The lib may need to be wrapped in a refine block.

                        I'm not here much anymore.

                        1 Reply Last reply Reply Quote 0
                        • E Offline
                          Ellipser
                          last edited by

                          @tt_su said:

                          Are you just doing computations? Or are you generating geometry?
                          For computations adding more Ruby code (ie another Ruby library) won't speed things up. I've had to resort to writing Ruby C Extensions to do calculations fast. For just doing math C/C++ isn't that scary. We got examples of projects in Visual Studio and Xcode on GitHub that have everything set up to toy around.
                          If it's generating geometry there might be ways to get better performance - bulk operations etc.

                          Do you have some code to look at - that way we would know exactly what we're dealing with here?

                          I'm generating geometry on this plugin:http://sketchucation.com/forums/viewtopic.php?f=323%26amp;t=57790

                          I took a class in C++, so I can do that, and have done a significant amount of C++ for embedded microcontrollers.

                          I'd like to learn how to interface C++ with Sketchup, so I can speed things up. Basically my problem is that I need a road-map of sorts to get there.
                          First thing is, what C++ compiler should I use? Visual Studio? I don't want to pay Bill Gates $500 for just hobbyist work that I'm doing. I used DevC++ before. I'm not at all familiar with Xcode, so I guess I'll Google that after I'm done writing this post.

                          I've seen the SDK code on the Trimble site, but, what next? Step 1 would be of course to download a C++ compiler. Then what? Where do I put all the header files? Could you recommend a tutorial if there is one?

                          Ultimately, I'm going to interface Sketchup with my 3D printer, which is in the final stages of being made. (It already does plotting when provided G-code). Next step is mounting the extrusion head and generating G-code from a Sketchup file. Also, with just using the Dremel mount I have, I can do milling. I want to do some Celtic designs created in Sketchup and then milled into wood.

                          Thanks for you time, btw.

                          1 Reply Last reply Reply Quote 0
                          • Dan RathbunD Offline
                            Dan Rathbun
                            last edited by

                            FYI: GCode project that needs someone to take it up.
                            http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=54636

                            I'm not here much anymore.

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

                              @ellipser said:

                              I'd like to learn how to interface C++ with Sketchup, so I can speed things up. Basically my problem is that I need a road-map of sorts to get there.
                              First thing is, what C++ compiler should I use? Visual Studio? I don't want to pay Bill Gates $500 for just hobbyist work that I'm doing. I used DevC++ before. I'm not at all familiar with Xcode, so I guess I'll Google that after I'm done writing this post.

                              https://github.com/SketchUp/ruby-c-extension-examples
                              That git repo includes Visual Studio and Xcode project examples for an Hello World extension - including the Ruby libs and headers we use.

                              @ellipser said:

                              I've seen the SDK code on the Trimble site, but, what next? Step 1 would be of course to download a C++ compiler. Then what? Where do I put all the header files? Could you recommend a tutorial if there is one?

                              The C SDK is for reading and writing SKP files -not for acting on the live model.

                              @ellipser said:

                              Ultimately, I'm going to interface Sketchup with my 3D printer, which is in the final stages of being made. (It already does plotting when provided G-code). Next step is mounting the extrusion head and generating G-code from a Sketchup file. Also, with just using the Dremel mount I have, I can do milling. I want to do some Celtic designs created in Sketchup and then milled into wood.

                              Nice! Got a project blog?

                              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