How do I get Mathn.rb to work?
-
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?
-
@jim
if I restart SU and try this without therequire '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
-
But how many plugins count on the Math module not changing behavior?
-
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
0require "mathn"
truem = 2 / 3
(2/3)n.class
Fixnumm.class
Rational` -
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.
-
@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. -
@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.
-
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?
-
@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. -
@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.
-
FYI: GCode project that needs someone to take it up.
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=54636 -
@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?
Advertisement