What if we could use <blank>?
-
@jessejames said:
WOW!, your comments show a deep seeded hatred for Python. Where is this coming from Todd?
You are going down a dead end road, JJ. I don't know Python. I don't know how to wallpaper. I don't know how to ballroom dance. I don't know you. I hate none of the above. As it stands rights now, of the above, the only one I would care to learn about would be you!
-
I'm not much of a script programmer, my experience is mostly in c++ and c#. My forays into ruby are really my first experience with script languages. Not experiencing other choices, I'd have to pick ruby. I like that you can inherit classes; I don't like that it's a little to loose when it comes to that . I really like how easy it is to extend ruby with c and c++, and the tools available in c to communicate with ruby. I hate ruby's garbage collection (but that's only an issue when extending in c/c++). So good and bad, but having nothing to compare it against, I say it's good enough.
Avariant's pick: Ruby
-
@unknownuser said:
@jessejames said:
WOW!, your comments show a deep seeded hatred for Python. Where is this coming from Todd?
You are going down a dead end road, JJ. I don't know Python. I don't know how to wallpaper. I don't know how to ballroom dance. I don't know you. I hate none of the above. As it stands rights now, of the above, the only one I would care to learn about would be you!
Hello again Todd,
So you want to get to know me eh? A little chit chat? Ask away, these are free and open forums ASAIK -
JJ, some of your comparisons are clearly misleading. I haven't seen one thing that Python does that Ruby doesn't. The grammar may be slightly different, but they do the same thing (including "list comprehension"). Ruby has the identical functionality, but the syntax is different. You're wasting time as far as I'm concerned. This is a "religious" argument and your "religion" is Python. Threads like this will not end in anything but wasted time and hard feelings.
-
@david. said:
... Ruby is not simply derived from Perl, it has also borrowed from Eiffel, Smalltalk, Lisp, and Ada.
And the best things about Ruby are borrowed from Python.
@unknownuser said:
1Q.)For the most part, I'm with Todd on this... why introduce another programming API into SU? It's not worth the effort. The quality of the SU Ruby API documentation has nothing to do with the choice of Ruby. It has everything to do with taking the time to produce. As in most software projects, documentation is generally the lowest priority on the schedule. That's certainly the case for the SU Ruby API. If Python had been chosen as the SU programming API, then I'd be in favor of keeping it. But, it wasn't.
2Q.)Do you think it would be a good investment of time to create another programming API for SU when one already exists? ...These are all good questions and i will give good answers for them.
1A.) Look, an API is for users to wield the full power of an application(or maybe just automate a simple task), not so a few at the top can make money writing scripts because the language is poorly documented and overly complicated.
I have nothing against the professionals who want to write professional plug-in/scripts. But at least give the users of that application the common sense tools they need to get their scripting done, so don't handicap them with a poor language choice (Ruby)
I want to give every SU user the ability to write useful scripts for them selfs. My number one complaint about Ruby is Poor documentation. Ruby has no good free introductory tutorials. But Python has tons and tons of good free tutorials that cover vast amounts of programming tasks. At the following link, there are 300+ Python tutorials listed in more than 50 Categories, and this is just one site!!!
300+ tuts
http://www.awaretek.com/tutorials.htmlHere is a list of nonprogrammer tuts:
http://wiki.python.org/moin/BeginnersGuide/NonProgrammersHere is a list of experienced programmer tuts:
http://wiki.python.org/moin/BeginnersGuide/ProgrammersRuby cannot touch the amount of good docs available for Python.
2A.) Yes, i absoulty think bringing in Python -- even next to Ruby -- would be a great idea. This would give all SU users the power they need. Not only do i think this is a great idea, i am willing to spend my time(free of charge)to make this happen. Even if i have to do it completely alone. That is my commitment! I have no will to make capital gains on the SU users. My goal is to extend their SU experience.
I plan write an introductory tut specifically targeted at SU users with no programming experience for SU Python scripting. Not only that, i plan a much better console for SU. You may say, why do we need a better console, a console is only good for trying out short pieces of code. I say Yes, this is exactly how a n00b learns. They type a command and see the results right away. The single line console in SU is almost useless and could easily be improved. Noobie's have a problem understanding how to format code to fit on one line.
Skethchup.active_model.selection[0].offset(-3)
or this
def f;for x in model.selection; x.this;x.that;end;end
All that does is serve to frustrate and defeat the user before they have a fighting chance. A multi-line console will ease the learning curve.
PYTHON GUI
Also Python has a built-in GUI(Tkinter). Tkinter is a very easy to use GUI toolkit, which contains all the main widgets a GUI needs, built right into the language. How would you like to have that on board for ya scripting pleasure, eh?here is a Tkinter program that contains a button widget
from Tkinter import * root = Tk() def call(); print 'Hello SketchUp' Button(root, text='Press Me', command=call).pack() root.mainloop()
That short piece of code creates a main window with a button that prints 'Hello SketchUp'.
Look, i want to improve this great software for everyone. The more people we have coding, the more ideas and improvements we can bring to SU. Let's empower all SU users!!
-
@david. said:
I'm having difficulty finding any major differences between Python and Ruby. The "Hello World" example you cited can be coded exactly the same in Ruby.
Hello David,
You right, the hello world in Ruby looks exactly like Pythonprint "Hello World"
Python and Ruby share many likeness because Ruby took them from Python, which is OK, i don't mind. But Ruby and Python are very different also -- VERY different.
don't forget to scroll down on the Ruby code
RUBY WAY:
module YourNameSpace class MyClass def method1(arg) if arg == this do this elisf arg == that do that else do that end end end require "scriptname" YourNameSpace;;MyClass.new
PYTHON WAY:
class MyClass; def method1(arg) if arg == this; do this elif arg == that; do that else; do that from scriptname import MyClass instance = MyClass()
First thing you will notice is how clean Python code looks to the eyeballs. No need to declare a module, The script IS the module. Now you have a nice clean namespace and did not even have to worry about it! Also notice Python does not use an ugly and redundant "end" statement.
This is just a very simple syntax comparison, wait until you try regular expressions, or string formatting, or list comprehensions (Oh wait, Ruby can't do that one).
Ruby looks too much like Perl. If you like S&M, well i guess Ruby is your language. If you want to get things done in the easiest and most painless way, Python is your common sense approach to everyday programming! Which makes it the perfect scripting language
-
@remus said:
Are you a fan of python by any chance?
Maybe just a wee bit
@unknownuser said:
Although this doesn't require a language I know having the ability to record and save a set of proceedures as a macro (while building a model) would be useful and could be a replacement for a lot of simple rubies.
I very much agree for those needing a simple repetitive action or what-not. But here again you will be limited. You could do so much more with a little bit of code. Not only that, learning a few things about programming can be transfered to automating tasks on your machine, and/or other scripting languages/programs.
Programming is not rocket science, and scripting of an API is nothing more than saying to SU "Hey, do this if this condition: else do that". The base code is already there, all you have to do is call the methods(). Just as your car is already designed, engineered, and built for you, so is the SU API. All you have to do is put a little gas in, turn the key and go! It is really not as hard as you think. But i think the barrier here is Ruby. (see next section)
@pixero said:
How about a thread with ruby programming tutorials for everyone?
Very good idea, and I am already two steps ahead of you. I have started a tutorial for non-programmers. The main purpose is to get them over the initial "hump" quickly and show how easy it really is to write useful scripts. I have postponed it for now because i found as i was writing the tut, how teaching/learning would be so much more simple if Python were available.
SketchUp is changing the world of 3D modeling much the way Python changed the world of programming. I see a great future for this software. It is evolving rather quickly, and has brought many people to the wonders and joys of the modeling world(novice and professional alike). I only want to guarantee this future upwards evolution by giving people the common sense tools they need to wield the full power of this great application. SU is truly the only software i have seen that can carry the title of "21st century software"
The combination of Sketchup's intuitive and ground-breaking UI, coupled with the common sense approach and simplistic elegance of Python will be an unstoppable force. Not only will this expand SketchUp's influence, but will give a SketchUp user the complete power they need over the application -- in the quickest, and most painless way.
SU users need a language that...
1.) is easy to learn
2.) is widely supported
3.) is open source
4.) Has ample, AND clear documentation (most important)*and if you can teach good programming principals in the process, what a plus!!
Python fits all these and then some. Modelers need to concentrate on modeling, but they also need the power scripting brings, and a lot of you do not realize this power yet, but i want to change that. If Python were here i would not need to write a tutorial, i would just point you to one of the great tuts that already exist out there.
For those that don't know anything about either language i will explain. Ruby and Python are by far the only two "very high level" languages that exist today(IMO) -- High level simply means easy to use.
Ruby is a language with lots of shortcuts and has many ways to do the same thing. But these shortcuts make learning the language painful for non-programmers, and even experienced guy's like myself. This is because there are more rules to learn, more syntax, and two scripts can look wildly different. Ruby is a direct descendant of Perl(a very powerful, but VERY cryptic language). If you are a Perl programmer, you would love Ruby.
But if you are a non-programmer or a C programmer, you will find Python very easy to learn. I believe Python is the perfect scripting language for any software. Python revolutionized programming the way SU revolutionized modeling. SU is made for modelers, not professional programmers, so I believe Ruby was the wrong choice in this regard. Not everybody wants to, or needs to script SU. But for those that do, i want to give you a fighting chance. The pros can learn any language, this is about making SU more useful to EVERY SINGLE USER.(and lots of pro's love Python too)
Let me tell you the perils that a SU user faces on his quest to learn SU scripting. The first thing this user must overcome is his sense of self worthlessness. The "I can't possibly write code" syndrome. Once this person finally builds enough self courage to overcome this monster, a new and more powerful one awaits around the corner. Poor documentation. I am not just talking about the SU API(which is better than most API's). This extends well into the world of Ruby itself. I have yet, in my months of looking to find a decent tutorial for the Ruby language that i can suggest for struggling SU users. There exist no Ruby tutorial that will ease a new programmer into the language. The SU API docs have some shortfalls too. They are missing some real good examples, and the links to example scripts are broken! This is a travesty to all new SU scripters.
PYTHON HISTORY
Python came into being around 1991 by a computer science genius named "Guido van Rossum". This man is truly a man before his time(currently works at Google). Python revolutionized the world of programming and showed other languages how easy programming should be. Python promotes good coding styles by indentation, syntax is clear, and choice of keywords is perfect. I like to think of Python as simplistic programming elegance. No other high level language can compete with Python.There are literally hundreds, and i would say even into the thousands, of good free tutorials across the web for Python for all levels(beginner to pro). Not only is the language easy to learn, you will never be without clearly written tutorials for this language. The community is huge, and many people follow this language. Python is by far the easiest of all languages to learn for non-programmers and just as powerful as any other high level, i can speak from experience.
Hopefully people will come to their senses and demand a change or the inclusion of the Python programming language next to the Ruby API. For it will be for your benefit SU users.
PS: Did i mention that Python is Google's official language of choice. That Google uses Python in their search engine and applications. Python is also used by Nasa, Industrial Light and Magic, and many more respected people. It pretty much runs YouTube.
check here for more details
http://www.python.org/ -
@unknownuser said:
OK, I'll bite.
C++.
For processing intensive scripts, the speed would be awesome.
Todd
OK Todd, Show the good people here a hello word program in C++ and then in Ruby and Python.
If you want to write a...
a.) OperatingSystem
b.) 3D game of the year
c.) Graphic Software(SU)
d.) Device Driver
...then C++ is your language.It would take hundreds of lines of code to write even the simplest of scripts. And you would need to compile a version for every platform.
Sorry Toddy, low-levels are just not any good for scripting. With that attitude why not just use assembler? Or wait, i have an idea, just write binary 1's and 0's, and spoonfeed them to your processor
PS If you are really serious about scripting SU with C++, I hope at least you have a good carpal tunnel specialist on retainer
-
@david. said:
JJ, ...Threads like this will not end in anything but wasted time and hard feelings.
I carry no hard feeling towards anyone. I simply state my points, that's all. I welcome everyones point-of-view, even if they are totally against me. Free speech rules in my world.
It is good to question the status quo from time to time. Revolution is a very natural and needed process. And if you have to storm the palace and "let some heads roll", Oh well. It will be for the betterment of all mankind.
The advancement of knowledge/Technology is a never ending pursuit. Grow complacent and you shall grow extinct!
-
Sketchup challenge
Ruby(0): +1, you can use it with Sketchup
Ruby(1): +1, it is used by many people to improve SketchupSketchup challenge - result:
Ruby 2:0 PythonConclusion: I think, I should use Ruby to improve Sketchup instead wasting time explaining all the advantages of progamming language XYZ. Let's call it: Pragmatic programming.
Btw. The rubyfied school example:
class SchoolMember def initialize name, age @name = name @age = age end def to_s "Name; \"#{@name}\" Age; \"#{@age}\"" end end class Teacher < SchoolMember def initialize name, age, salary super name, age @salary = salary end def to_s super + " Salary; \"#{@salary}\"" end end class Student < SchoolMember def initialize name, age, marks super name, age @marks = marks end def to_s super + " Marks; \"#{@marks}\"" end end t = Teacher.new 'Mrs. Jones', 40, 30000 s = Student.new 'Jack', 23, 75 [t, s].each { |m| puts m }
Hope, you like the short lines.
azuby
-
@jessejames said:
PYTHON GUI
Also Python has a built-in GUI(Tkinter). Tkinter is a very easy to use GUI toolkit, which contains all the main widgets a GUI needs, built right into the language. How would you like to have that on board for ya scripting pleasure, eh?here is a Tkinter program that contains a button widget
> from Tkinter import * > root = Tk() > def call(); print 'Hello SketchUp' > Button(root, text='Press Me', command=call).pack() > root.mainloop() >
That short piece of code creates a main window with a button that prints 'Hello SketchUp'.
Look, i want to improve this great software for everyone. The more people we have coding, the more ideas and improvements we can bring to SU. Let's empower all SU users!!
I have been looking for a better GUI solution. And quite frankly I'm disappointed that not more has happened with the Ruby API, since the release of SU7. It appears that Ruby is stuck where it is right now. And I'm not quite sure what Web Dialogs are going to do for SU going forward. I would like to hear from some of the other Ruby experts we have in this Forum. The attachment below may be a it ambitious but I would like to have the capability to produce such a GUI. And if Python has that capability, I'm on board. Modo is capable of using Perl and Python scripting. Why should SU not embrace Python as well?
-
Now please don't all beat me at once...
We use PC's, I'm a very part time coder, most of my time I just use software but I occasionally code macro's for -
Inventor
AutoCAD
Word
ExcelWhat do they have in common (currently)-- VBA
Four pieces of significant software, one basic language for the macro's.OK, I know I won't get VBA on SketchUp, but it would be really nice to get commonality of macro programming language across major applications. Probably no chance though.
P.S. - I have used Ruby on SketchUp
-
Tomot - have you seen wxWidgets? Peter Ellis put out support for it for use under SketchUp back in October.
Blog article: http://sketchupapi.blogspot.com/2008/10/wxsu-and-you.html
-
@avariant said:
I'm not much of a script programmer, my experience is mostly in c++ and c#. My forays into ruby are really my first experience with script languages. Not experiencing other choices, I'd have to pick ruby. I like that you can inherit classes; I don't like that it's a little to loose when it comes to that . I really like how easy it is to extend ruby with c and c++, and the tools available in c to communicate with ruby. I hate ruby's garbage collection (but that's only an issue when extending in c/c++). So good and bad, but having nothing to compare it against, I say it's good enough.
Avariant's pick: Ruby
You really need to check out Python. Your C mind will love it. Python supports full OOP and True procedural programming. No need to use instance vars (@var or @@var) when writing procedural code. Python is fully OOP. Here is a simple example of inheritance.
NOTE: the return line in the str() method is wrapping due to this groups display of text. this should be one line
class SchoolMember(); def __init__(self, name, age); self.name = name self.age = age def __str__(self); return 'Name;"%s" Age;"%s"' % ( self.name, self.age) class Teacher(SchoolMember); def __init__(self, name, age, salary); SchoolMember.__init__(self, name, age) self.salary = salary def __str__(self); return '%s, Salery;%d' % ( SchoolMember.__str__(self), self.marks) class Student(SchoolMember); def __init__(self, name, age, marks); SchoolMember.__init__(self, name, age) self.marks = marks def __str__(self); return '%s, Marks;%d' % ( SchoolMember.__str__(self), self.marks) t = Teacher('Mrs. Jones', 40, 30000) s = Student('Jack', 23, 75) for member in [t, s]; print member
And here is the output from that session:
Name;Mrs. Jones, Age;40, Salary;30000 Name;Jack, Age;23, Marks;75
As to your liking of extending Ruby with C, the same can be done with Python using built-in ctypes. But for those who do not know C, or do not want to know C, Python has something much better, Pyrex, and Pysco.
@unknownuser said:
Pyrex -- is a language specially designed for writing Python extension modules. According to the Pyrex Web site, "It's designed to bridge the gap between the nice, high-level, easy-to-use world of Python and the messy, low-level world of C." Almost any piece of Python code is also valid Pyrex code, but you can add optional static type declarations to Pyrex code, making the declared objects run at C speed.
@unknownuser said:
Psyco -- to keep it very short -- is a just-in-time (JIT) compiler of Python code into (x86) machine code.
Python has everything a non-programmer to pro needs. A very highlevel language using common sense approach to programming, extendable with C, and easily flys with Pyrex and/or Pysco!
-
I thought the thread was about using <blank>, not a decoy to try to convert from Ruby to python.
As for the tutorials, I am doing a nice ruby tutorial. Its pretty good for the syntax. But like others have stated, it would be easier if there were tutorials based entirely on a SU workflow. Its hard for my brain to understand how to implement some of the stuff I'm doing in the tutorial into SU. So more SU based ruby tuts would be grand. So quit jabbering and get making
btw, I've only taken 1 programming class and it was pascal. I don't really care what SU uses, but if it switched off of ruby right after I take the time to learn ruby, I'll be pretty upset.
Chris - not a programmer, just a dreamer.
-
@tomot said:
I have been looking for a better GUI solution. And quite frankly I'm disappointed that not more has happened with the Ruby API, since the release of SU7. It appears that Ruby is stuck where it is right now. And I'm not quite sure what Web Dialogs are going to do for SU going forward. I would like to hear from some of the other Ruby experts we have in this Forum. The attachment below may be a it ambitious but I would like to have the capability to produce such a GUI. And if Python has that capability, I'm on board.
Hello tomot,
You could easily write up a GUI for that with a very minimal amount of code using Tkinter, i will even write up a clone example if you want to see it!(send me a PM)Python also has wxPython module available that will give you all the great and awesome power WX provides. Of course WX takes quite a bit more to code than Tkinter, but it is a very powerful toolkit for professional quality GUI's
The great thing about Tkinter is the "every day" SU scripter(and not just the pros) can write GUI code easily, and it is built right in to the Python language!
@tomot said:
Modo is capable of using Perl and Python scripting. Why should SU not embrace Python as well?
I can assure this group, if we could get Python into SU, people would love it. Let the users decide what language is better (heck let them have both!). Python has the docs, the built in GUI, and has been proven since 1991.
And you have my commitment to build the Python API. If some of you want to help out, great. If not i will make this happen and you can enjoy the benefits. These two languages are the only choices for scripting, but Python gives you the extra advantages that Ruby simply can't.
If we don't get Python. Some serious effort needs to be made to create a SU Ruby beginners tutorial, SU API doc improvements, a multi-line Ruby console, and a real GUI toolkit for Ruby! Web dialogs are no going to cut it. We need real File Dialogs, Message Boxes, Widgets, etc... and we need them NOW!
-
Well, since your working on your tutorials, I'll throw in my requests.
I'm following the tutorial here:
http://pine.fm/LearnToProgram/
Its great. But it explains ruby as a language for stuff I don't care about. so its helped a bunch with the syntax, but for me I'd rather have tutorials that help walk me through the same steps using SU as the base, instead of the command prompt.
So do that and we'll be ready to roll.
Chris
-
@chris fullmer said:
I thought the thread was about using <blank>, not a decoy to try to convert from Ruby to python.
This Thread is about giving SU users the common sense tools they need to use SU to it's fullest capabilities. I want to hear everyones opinion on this subject. SU noob to pro! If you are with me, or against me, does not matter.
@chris fullmer said:
As for the tutorials, I am doing a nice ruby tutorial. Its pretty good for the syntax. But like others have stated, it would be easier if there were tutorials based entirely on a SU workflow. Its hard for my brain to understand how to implement some of the stuff I'm doing in the tutorial into SU. So more SU based ruby tuts would be grand. So quit jabbering and get making
btw, I've only taken 1 programming class and it was pascal. I don't really care what SU uses, but if it switched off of ruby right after I take the time to learn ruby, I'll be pretty upset.
Chris - not a programmer, just a dreamer.I am working towards a solution as we speak.
One solution would be to fix Ruby. This is a grand undertaking because this is a Ruby problem ,and the SU community has little control over Ruby direction. A lot must be done here -- A good introductory tutorial aimed at SU Ruby scripters with no programming experience, and dive-in tut for experienced programmers new to Ruby SU scripting, a multi-line Ruby console, real GUI support, and improvement of the current API docs. So far SU has been around for 9 years and none of this has happened yet. WHEN IS THIS GOING TO HAPPEN? WHERE IS THE CALLING FOR IT? WHERE IS THE COMMUNITY ON THIS SUBJECT?
The other solution would be to INCLUDE a Python API in SU. Python has the docs, and the built-in GUI already. It would be disastrous to wake up tomorrow with Ruby gone and Python in it's place. Many people have invested hours, days, months and years building awesome scrips and plug-ins for SU. That's why I want to ADD Python, NOT replace Ruby. I want to give SU user the choice here because i believe Python has much more to offer. Some people will stay with Ruby, most(i think) will join the Python bandwagon. All of this will be for the betterment of SU. That is my point here.
-
I see, you do NOT care about Ruby, jj. You do not look for information - instead YOUR only wish seems to be having Python for improving Sketchup. No problem with that, but it is only YOUR wish.
Ruby has GUI support for:
TK
wxWidgets
Qt
GTK
Fox
WebDialogs for SketchupMulti line consoles:
WebConsole - http://sketchuptips.blogspot.com/2007/08/plugin-webconsolerb.html
d/Code - http://www.errorinitus.de/ => SoftwareYour first steps could be using a bridge between Ruby and Python (or use the Sketchup SDK to write your own lib):
Ruby/Python - http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/index.html
Ruby-Python-Bridge - http://www.vyperlogix.com/ruby-python-bridge/
pyRuby-Python-Bridge - http://pypi.python.org/pypi/pyRuby-Python-Bridge/1.7azuby
-
@azuby said:
...
Ruby has GUI support for:
TK
wxWidgets
Qt
GTK
Fox
WebDialogs for SketchupAre any of these built-in?
@unknownuser said:
Multi line consoles:
WebConsole - http://sketchuptips.blogspot.com/2007/08/plugin-webconsolerb.html
d/Code - http://www.errorinitus.de/ => SoftwareI am talking about the Ruby Console in SU. Ruby has many good editors but not embedded directly into SU.
@unknownuser said:
Your first steps could be using a bridge between Ruby and Python (or use the Sketchup SDK to write your own lib):
Ruby/Python - http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/index.html
Ruby-Python-Bridge - http://www.vyperlogix.com/ruby-python-bridge/
pyRuby-Python-Bridge - http://pypi.python.org/pypi/pyRuby-Python-Bridge/1.7This is exactly how i want to start. The reason for this thread was to test the waters for SUuppers who would be interested in a Python API. From here i plan to get Python talking to Ruby, build support and see where it goes from there. Are you interseted in having more choices azuby?
Advertisement