Thursday, April 26, 2012

I'm here to assure you that Trimble is committed to preserving the vitality of SketchUp’s developer community. You guys have made SketchUp great, and we have every expectation that opportunities will grow for you as we continue to develop SketchUp at Trimble.

It's often said that people building plugins have more to do with SketchUp's success than anyone else, and I couldn't agree more. In the years I've been at Google, the most rewarding part of my job has been interacting with all of you and seeing the amazing features you've created.

In the short term, this change will have zero impact on your plugins and businesses. Everything will work exactly as it does today. In the longer term, I expect it to improve the state of our APIs and developer resources. Trimble wants to invest strongly in SketchUp as a platform, and advance its mission of "3D for Everyone."

I'm very excited to be joining in this next stage of SketchUp's journey. See you all on the other side!

Thursday, December 1, 2011

In the latest and greatest SketchUp 8 maintenance release, M2, we added an easier way for users to install your Ruby scripts. In the past, folks had to manually copy your .rb files into their Plugins folder, or you would have to write a custom installer to do it for them.

Now there's a button in SketchUp that'll make this easier. It's found under Preferences > Extensions > Install Extension. Clicking this button will bring up a file browser window where your users can select any .RBZ file from their harddrive, and SketchUp will put them in the right spot plus load them up. No more fumbling around looking for the Plugins folder. No need to restart SketchUp to see your shiny plugin.

But what is an RBZ file?

And how do I make one?

It's simple. RBZ files are nothing more than ZIP files. You can use your favorite ZIP tool (I like 7-zip on Windows) to create the archive, then rename it to have a .RBZ extension. Anything you put inside of this RBZ file, including files and subfolders, will be unpacked into the user's Plugins folder. That's it!

So let's say you had a plugin with the following files in it:

SketchUp 8/Plugins/helloworld.rb

SketchUp 8/Plugins/helloworld_files/hello.html

SketchUp 8/Plugins/helloworld_files/smiley.png

You would create a ZIP file containing the above files. With my ZIP tool, I simply select the helloworld.rb and helloworld_files folder, right click on them, and select "Create ZIP". The resulting file is called helloworld.zip. Right click > rename to helloworld.rbz, and you're golden. HOWEVER, before I do this, it would be even better to change my simple ruby script into a SketchupExtension. That way my users will see your Extension added to the Extensions panel when they do the install, and in the future it's easy for them to turn it off.

But wait! What about the parent class? A Vertex is an Entity, and so I can call any Entity method, too. Maybe there's a transform() method on the Entity class...

Nope.

At this point, you might have given up. (I know I did the first time I tried this...) But don't! The secret is that Entities.transform_entities can accept naked vertices as well as edges and faces. This wasn't obvious to me because if you iterate over the Entities collection, it doesn't contain vertices! So I just assumed that the transform_entities method wouldn't work on vertices. I was wrong, though. It'll accept any Entity, just like the documentation says. Check this out...

Wednesday, August 3, 2011

In the world of Ruby scripts, keep in mind that users who will install your SketchUp plugin probably have installed other SketchUp plugins, too. Since Ruby is a wide-open language that lets you override and inspect just about anything, this can lead to bugs where your plugin conflicts with someone else's.

So before you distribute your hot new plugin, don't forget to follow these important steps:

Try to know what others are doing/have done.

This isn't always easy, but some research and questions go a long way in avoiding conflicting class/method names. It can also prevent you from duplicating someone else's effort - why re-create method x when it's already been written? Just tap into it and go (with permission, of course). Look for public scripts that are doing similar things to what you're acconplishing, and consider working with that author to cross-promote your tools. Sometimes, the already-written code won't do exactly what you want. In that case, you can either subclass yours and modify the methods (for classes, obviously), or write your own using a different class/method name.

Try to use unique names rather than common ones.

For example, if you write a "ProgressBar" class, you will cause conflicts with any other "ProgressBar" class. That will make for unhappy users, as they try to get tech support for something the author says works just fine on his machine, but clearly won't work on their machine; and will make for unhappy fellow developers, who have to hunt down the conflicting script, locate the author, and try to work out a solution. Better to do something like "mskp_ProgressBar" which is unlikely to collide.

Encapsulate methods in a Module or a Class.

Within a class, you don't have to worry about method naming conflicts, and within a module, you can be less careful about both class and method names.

Test your work against as many other works as possible, and test them against yours.

Unfortunately, the burden of compatibility will more than likely fall to the second developer. However, if you send your script to other developers asking them to test for compatibility with their works, they'll most likely be happy to oblige (subject to their own time constraints, naturally). This will help keep the user experience (and your reputation) positive.

Be respectful of the Plugins directory structure.

If your plugins has a lot of support files (piles of .rb files, html file, image files, etc.), group them together into a subdirectory under the Plugins folder. This will make it easy for users to identify (and potentially uninstall) your script. It will also make it less likely that your "cursor.png" will by overwritten by someone else's "cursor.png".

Document your code and include contact information.

Write generous comments and include a header block at the top of your scripts that tells people what is included with your Plugin, what it does, and how to contact you in case of upgrades or bug reports.

Thanks for Rick Wilson for the original post that I took these tips from. Code on!

Thursday, July 21, 2011

Around the office here we're always amazed at the awesome Ruby scripts you developers create. They make SketchUp more productive, smarter, and downright snazzy. So it's no surprise when we hear from users who have a lot of plugins installed.

Plugin management can get really difficult, though. If two scripts conflict with each other somehow, SketchUp can go haywire, and figuring out which scripts are the culprits can require a lot of detective work. If only all of the ruby programmers out there used SketchupExtensions... ahh, the world would be so much nicer.

SketchupExtensions are a handy-dandy way for you to package your plugin that is easier for users to toggle on and off. You can see the extensions you already have under Window > Preferences > Extensions. With a quick click, you can learn about who authored each of them and can even turn 'em on and off. It's dandy!

And the cool thing is that an extension is nothing but a normal Ruby plugin wrapped in a little bit of extra code. Making one of your own is easy and well worth your time. Here are several advantages:

Makes it easier for your users to turn off your script if they don't need it at the moment

Makes customer support easier for you, because you can track plugin versions

That's all there is to it. When you restart SketchUp your plugin will load as before, but now people can control it in the Preferences panel. We highly recommend that you do this with all of your plugins that extend SketchUp's UI with buttons or menu items.

Whoohoo! One little flag and now it runs in 4.7 seconds. That's a 25% increase in performance for typing six keys on my keyboard.

If you're already using Model.start_operation in your plugins, this is a change worth making. If you're not, you should be. In addition to this performance increase, start_operation groups all of your model changes into a single "undo," which makes your plugin easier on your users.

What Ruby performance secrets do you know? Let's hear 'em in the comments!

Thursday, September 2, 2010

As many of you already know, we released SketchUp 8 yesterday. Check it out: http://sketchup.google.com/

We have updated the documentation for the Ruby API and you can find the Ruby API release notes at: http://code.google.com/apis/sketchup/docs/releases.htmlEnjoy!Posted by Simone Nicolo, Google SketchUp team.