Ruby Console woes
-
@chris fullmer said:
Well, quit trying to write code in the console. Move over to Jim's webconsole, as was suggested previously. I've found it to be quite useful! It allows multi-line editing, which is very usfeul.
Thanks, but i tried before with no results. Does it have an issue on Winders/Vista?
@chris fullmer said:
Good to see you back on the forum JesseJames!
Thanks, great to be back, i been out trail ridin' far too long, Whew! you know any good remedies for saddle rash?
-
@chris fullmer said:
I agree, but even if it has shortcomings, it is still a zillion times better than just using the console and a text editor!
That's the truth, the whole truth, and nutt'in but the truth Chris!
The Ruby console as it is today, is a barrier to learning the Ruby language for SketchUp noobies and oldies alike. As for myself, I finally made it through my "acid bath" introduction last year and i can tell you it felt like the "trials of Job" had been cast on me!
Since the Ruby console is the gateway to SketchUp scripting, NO WONDER people are scared to death of writing scripts for SketchUp! I can't imagine the trials and tribulations a non-programmer would face.
Interactive multi-line consoles like the Python IDLE shell, are the best place to "get to know" a programming language. And it does not stop there... oh No, quite the contrary! Even after learning the language testing out small code snippets for functionality is paramount to productivity!
Too bad SketchUp is closed source because i know a lot of "gracious" folks out here would like to make SU an even better tool than it is today, and would not even charge a penny for those services. Heck! i would do it even for the proprietary SketchUp as a thanks for Google allowing me to use this great software.
SketchUp is the only proprietary software i have ever used that has that liberating feeling of OpenSource.
-jj
-
@jessejames said:
I can't imagine the trials and tribulations a non-programmer would face.
Ha!, that's me! Before Ruby (which I just started in Jan. of this year), I only barely had a limited understanding of what programming languages were all about. I did not know how to program in an language. So Ruby is really my first language.
@jessejames said:
Interactive multi-line consoles like the Python IDLE shell, are the best place to "get to know" a programming language.
I agree completely that interactive multi-line concoles are the most important thing. I is where I learned Ruby, and I continue to test snippets in it.
And its too bad the web console has not worked for you. There are no known issues with WinXP or Vista. I've used it on both very succesfully. Try installing again. There should be a webconsole.rb file in your main plugins folder and then a webconsole folder with all the supporting files in it.
Then you start it in Plugins > WebConsole (though I've set mine as a shortcut to F5 because I use it so often). With it, I often write small snippets to do repeated tasks in my everyday modeling now. I tihnk you would like it.
Then from there we could discuss what ELSE could be added to a multi-line editor. Perhaps line numbering, syntax highlighting. It is my understanding that all those things would be possible to implement into an html inputbox like Jim's WebConsole.
Chris
-
@chris fullmer said:
Then from there we could discuss what ELSE could be added to a multi-line editor. Perhaps line numbering, syntax highlighting. It is my understanding that all those things would be possible to implement into an html inputbox like Jim's WebConsole.
Finally! Someone that sees the truth!!!
Chris we need to put our minds together and build a useful multi-line-editor for SketchUp. Jim has a template and maybe we can build off of it.
Unfortunatly however, i know nothing of JavaScript or the web. I am an applications "kinda" guy so wxRuby or Tkinter would be more my cup of tea. But i will help in anyway possible because i believe this is SO important for SketchUp.
Heck maybe i will learn JavaScript at the same time!
Maybe after building something useful we can convince the SU guy's to package it with the source distro? But if not, at least it will be downloadable for those who need it.
-
Sorry for the run on monologuing here but i need to show you all something. One thing Python has that Ruby desperately needs is command line help and doc strings. I could lecture about it all day but let me just show you an interactive session...
here i import math and print all the available methods in the "math" module
>>> import math >>> dir(math) ['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'hypot', 'isinf', 'isnan', 'ldexp', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
Now i just want some info on math.hypot method
>>> help(math.hypot) Help on built-in function hypot in module math; hypot(...) hypot(x,y) Return the Euclidean distance, sqrt(x*x + y*y).
Now i just show help for whole module (line breaking are mucking up the text but you get the idea)
>>> help(math) Help on built-in module math; NAME math FILE (built-in) DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. FUNCTIONS acos(...) acos(x) Return the arc cosine (measured in radians) of x. acosh(...) acosh(x) Return the hyperbolic arc cosine (measured in radians) of x. asin(...) asin(x) Return the arc sine (measured in radians) of x. asinh(...) asinh(x) Return the hyperbolic arc sine (measured in radians) of x. atan(...) atan(x) Return the arc tangent (measured in radians) of x. atan2(...) atan2(y, x) Return the arc tangent (measured in radians) of y/x. Unlike atan(y/x), the signs of both x and y are considered. atanh(...) atanh(x) Return the hyperbolic arc tangent (measured in radians) of x. ceil(...) ceil(x) Return the ceiling of x as a float. This is the smallest integral value >= x. copysign(...) copysign(x,y) Return x with the sign of y. cos(...) cos(x) Return the cosine of x (measured in radians). cosh(...) cosh(x) Return the hyperbolic cosine of x. degrees(...) degrees(x) -> converts angle x from radians to degrees exp(...) exp(x) Return e raised to the power of x. fabs(...) fabs(x) Return the absolute value of the float x. factorial(...) factorial(x) -> Integral Find x!. Raise a ValueError if x is negative or non-integral. floor(...) floor(x) Return the floor of x as a float. This is the largest integral value <= x. fmod(...) fmod(x,y) Return fmod(x, y), according to platform C. x % y may differ. frexp(...) frexp(x) Return the mantissa and exponent of x, as pair (m, e). m is a float and e is an int, such that x = m * 2.**e. If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0. fsum(...) sum(iterable) Return an accurate floating point sum of values in the iterable. Assumes IEEE-754 floating point arithmetic. hypot(...) hypot(x,y) Return the Euclidean distance, sqrt(x*x + y*y). isinf(...) isinf(x) -> bool Checks if float x is infinite (positive or negative) isnan(...) isnan(x) -> bool Checks if float x is not a number (NaN) ldexp(...) ldexp(x, i) -> x * (2**i) log(...) log(x[, base]) -> the logarithm of x to the given base. If the base not specified, returns the natural logarithm (base e) of x. log10(...) log10(x) -> the base 10 logarithm of x. log1p(...) log1p(x) Return the natural logarithm of 1+x (base e). The result is computed in a way which is accurate for x near zero. modf(...) modf(x) Return the fractional and integer parts of x. Both results carry the sign of x and are floats. pow(...) pow(x,y) Return x**y (x to the power of y). radians(...) radians(x) -> converts angle x from degrees to radians sin(...) sin(x) Return the sine of x (measured in radians). sinh(...) sinh(x) Return the hyperbolic sine of x. sqrt(...) sqrt(x) Return the square root of x. tan(...) tan(x) Return the tangent of x (measured in radians). tanh(...) tanh(x) Return the hyperbolic tangent of x. trunc(...) trunc(x;Real) -> Integral Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method. DATA e = 2.7182818284590451 pi = 3.1415926535897931
This is what makes Python so intuitive to new users. It's a powerful tool! You can even create your own doc strings for classes and method/functions if you want to!
EDIT: I actually posted this same idea on comp.lang.ruby last year. And to my surprise "Mats" (ruby's creator) himself said that it would be a great idea! So the will is there...
-
I don't think your comparison is fair - you are not comparing apples to apples.
You are comparing the full Python language installation, with all its standard and non-standard libraries against Sketchup-ruby - which is Ruby in a single .dll and includes none of the Ruby language standard libraries you get with the full Ruby installation.
If Google had choosen to embed Python in Sketchup instead of Ruby, we would still have only a single .dll of Python, and it would include almost none of the Python language libraries - of which IDLE is one. So you instead of the crappy Ruby Console, you'd be stuck with the crappy Python Console.
If you are interested, here is a way to use Python for SketchUp: http://www.cosc.canterbury.ac.nz/greg.ewing/SuPy/
-
I did start an upgrade to WebConsole (and it does have syntax highlighting!)
-
One more thing - I don't disagree that a replacement for the Ruby Console would be welcome.
If you are up to it, I think the ruby command-line interface IRB could be hacked to use TDB's bridge to access Sketchup objects.
Or if IRB could be made to use the ruby.dll from the Sketchup folder - it would then have access to Sketchup objects. I don't know if these strategies would work, though.
-
JesseJames wrote:
@unknownuser said:Thanks, great to be back, i been out trail ridin' far too long, Whew! you know any good remedies for saddle rash?
Answer: Boudreaux's Butt Paste! I kid you not. That's the name. Also excellent for diaper rash. Jus' ax any Sout' Luzianna momma.
-
@jim said:
I did start an upgrade to WebConsole (and it does have syntax highlighting!)
Jim where is the file? I cannot find it on your blog I see Web Dialog but that is it. And the title of your dialog in the image is "Ruby Web Dialog 2"...
@mitcorb said:
Answer: Boudreaux's Butt Paste! I kid you not. That's the name. Also excellent for diaper rash. Jus' ax any Sout' Luzianna momma.
Ah yes. I have seen this in the grocery store. Very funny, thanks
-
@jim said:
I don't think your comparison is fair - you are not comparing apples to apples.
You are comparing the full Python language installation, with all its standard and non-standard libraries against Sketchup-ruby - which is Ruby in a single .dll and includes none of the Ruby language standard libraries you get with the full Ruby installation.Respectfully, I think you misunderstood my intentions Jim. I'm not saying "look" Python IDLE rules and Ruby console sucks. No. I am saying Python IDLE has some very good things going for it and i want to create a Ruby clone of it for SketchUp.
@jim said:
If Google had choosen to embed Python in Sketchup instead of Ruby, we would still have only a single .dll of Python, and it would include almost none of the Python language libraries - of which IDLE is one. So you instead of the crappy Ruby Console, you'd be stuck with the crappy Python Console.
Yes this is exactly right, i am trying to change that...
@jim said:
If you are interested, here is a way to use Python for SketchUp: http://www.cosc.canterbury.ac.nz/greg.ewing/SuPy/
Thanks Jim giggle. It was my crusading, and begging, and nagging last year (at the expense of my reputation to multiple communities) to everyone on planet earth including "Guido van Rossum" himself that brought about this module.
Greg Ewing shares my interest in Python and SketchUp and my crusading helped nudge him to make this module.(Thanks again Greg!)... SketchUp, you have not heard the last of SuPy, i can assure you of that.
But i am not against fixing Ruby also. I have learned alot about the language and now have a better respect for it. So that is why i want to create or improve on an existing multi-line-console for SU.
Jim,
I see you have posted an image of the new console, this looks wonderful!!! -
Let's do something about this.
-
@martinrinehart said:
Let's do something about this.
Hello Martin,
I knew enlightened minds like myself existed in SketchUp land, but just did not have the physical evidence until now. Well that's still only less than a handful of Python coders i have a count of... Myself, Greg, You, and a very interested fan tomot who stood by me last year through trials and tribulations and got nothing in return. And there where a few other seeming interested parties... (Sorry if i left anyone out)
hmm, not enough to start the revolution, but it's a start nonetheless!
But seriously,
Python IDLE is a great yardstick to judge entry level IDE's on. If you like "fancy" IDE's, well you will be disappointed with IDLE. But IDLE is built for one thing, introducing noobies to the Python programming language in a very comfortable way.So we all know that a new multi-line interactive console is desperately needed. I can't see why SketchUp dev would not alow us to build this for them, and then they could throw it in the source distro.
But we must get this into the core SketchUp release. If someone just releases another plug-in and that ugly Ruby console stays in SketchUp then we might all just as well download one of the already existing Ruby IDE's out there.
But a real Ruby SUIDLE("swiddle" or "sweedle") OR SUIDE("sweede") would be a god send for everybody! And Taking IDLE's modular approach we could start simple and just add to our hearts desire!
The current Python IDLE weighs in a 1.53MB but a lot of this can be trimmed. Only the most important features are really needed...
Minimum Features
-syntax highlighting
-bracket matchingIcing on the Cake
-code completion
-object browsing
-smart indent
-call tips
-"your wish here"But most importantly this whole redundant cycle of the current Ruby scripting experiance is quite laborious. Here is a short script that describes the process in painstaking detail...
from patience import * from meds import Prozac, Asperin rants = [ 'OMG!, not again!', 'rats, here we go again!', 'Somebody just shoot me already!', ] def lament(self); self.sanity -= 1 print random.choice(rants) def medicate(); self.swallow(Prozac, Asprin) count = 0 while self.sanity > 0; count += 1 if count % 5 == 0; self.medicate() self.write_or_tweak_code() try; su = SketchUp.open() try; su.test_script_functionality(); break except ScriptRuntimeError; self.lament() except ScriptLoadError; self.lament() finally; su.close() print 'Finally! \ It only took %d cycles to complete this task *sarcasm*' %(count)
...needs to go the way of the Dodo.
Advertisement