Learning Ruby and the SketchUp API

Thanks DanRathbun, good list of resources there.

I don’t know, compared to the code provided by Trimble, Automatic Sketchup seems on par to me.
They are both out of date. Automatic Sketchup is the only book that I have seen specifically for Sketchup.

I like it because it uses examples from the SketchUp API -I use it along with http://ruby-doc.org/ to fill in information about basic syntax and core Ruby usage.

For me it is more interesting to learn by doing actual Sketchup things since I do not have that much interest in learning Ruby for other applications. As a hobbyist and someone who is too old to ever be productive at programming I would just as soon not have to know the details about how the mouse works. I thought that the whole point of object oriented interpreted languages is so that non-pros would not have to learn the details.

Have you had a look at Martin Rinehart’s tutorial called ‘Edges to Rubies’

it’s also dated [uses some globals, code not always wrapped in namespace, etc…], but a lot of people find it clear to follow…

john

I had not noticed that one -thanks

These are also the main issues with Automatic SketchUp.

Yeah, I see what you mean. Automatic Sketchup if fairly brief and does not give a lot of help understanding the basics of Ruby.

Chris, I’ve made this point earlier: you are making life harder for yourself by trying to learn Ruby by studying SketchUp example plugins. Going this way you are mixing questions about basic Ruby (which tells you nothing about the SketchUp API) with questions about the SketchUp API (which is confusing if you don’t already know Ruby). Dan gave an excellent list of Ruby materials earlier. Why not start with them and come back with questions about the API once you understand Ruby?

I gave it in that specific order because that is what I myself did. I went through those tutorials in say one night. Then I took a week to completely read the “Pick-Axe Book” cover to cover.

Then I started studying the API docs. It took me awhile to find the examples and utilities extensions.

Back in those days, everything you found (example-wise) was written incorrectly. Not within a namespace module, classes used where modules should be, global variables in every script, etc. I was of the first to start bitchin’ about these sloppy practices. But it seems I’m in a minority of people that first read a book from cover to cover and the programming language reference before attempting to code in it. (But I always learned every programming or markup language that way. It just makes sense to “work on the foundation before setting the walls.”)

I suppose the reason is that I find long discussions about syntax boring.

The pickaxe book does a much better job of teaching basic Ruby but for me if you are not actually trying to do things then you can read and read and it is all just words.

For me seeing how things go together and trying things out makes learning faster.

There is just no easy way around the frustration of trying to learn this language though.

But I think you are right. I was trying to skip ahead further than I should have. I thought that I could assemble blocks but there are just too many basic rules that i do not understand.

There are myriad issues with the examples and with many plugins. Some are so poorly written that studying them to learn Ruby is like trying to learn English by listening to rap music. Many of the examples are ancient and haven’t been updated for more recent SketchUp releases. Plugins often contain workarounds for API limitations or obscure code that is that way just “because it worked”. Some plugins use advanced Ruby techniques that go completely over a beginner’s head. Also, the API contains enough poor documentation, quirks, and obscure techniques that much plugin code contains workarounds that have nothing to do with Ruby per-se. So, a beginner using them as teaching examples is led to ask questions that confuse Ruby usage with API issues.

Ruby is fanatically object-oriented. Depending on your background, this can make it either very easy or very difficult to learn. But as you said, it is hard to assemble the blocks when you don’t yet understand the glue!

Keep at it. It will come together eventually!

“There are myriad issues with the examples and with many plugins.”

Yes I learned that after the first week.
I created a little phonebook with FoxPro in the MSDOS days so the object oriented approach is very strange compared to that.

I’m making progress -I had to take three steps back though.

Indeed. We are in dire need of updating the examples and providing newer best practice examples.