Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Wednesday, June 10, 2009

Foray into Ruby for SketchUp

My biggest complaint about SketchUp models:
The pretty little lines turn into masses of thick black blobs when seen from a distance.

Plant models are the worst offenders, with hundreds or thousands of edges.

When I create a model I pick and choose which edges are visible and which are hidden, and it makes a huge difference. But often I am at the mercy of another modeler. What can you do then?

I learned just enough Ruby to create a basic solution. Here's the code:
model = Sketchup.active_model
entities = model.entities
edges = []

entities.each do |e|
edges.push e if e.typename == "Edge"
end

edges.each do |e|
e.hidden=true
end

model.definitions.each do |f|
f.entities.each do |e|
if e.typename == "Edge"
e.hidden = true
else
end
end
end
Pretty simple, no? But what does it do?

Basically, two things:
1. It searches for edges entities.
2. It hides everything it finds.

All the edges are hidden and we're done. Yeah!

Of course it only works on the whole model.

Wouldn't it be better if it worked on a pre-specified selection?
Can I get this as a drop down menu?
How about a button?
Or better two buttons?
What if I wanted to toggle sets of lines on and off?

Sure, you can do all that. And the author will leave all those options as exercises for the reader. Have fun!

Thursday, April 23, 2009

SketchUp Scripts and Renderers

Yesterday I presented "SketchUp Scripts of which I am Fond" for a portion of the San Francisco CAD Managers meeting. We also talked a bit about Rendering programs. Here are the links:

Scripts:
www.smustard.com
S-mustard
(Goes with S-ketchup) an e-store that has lots of excellent scripts. Some are free others you pay for. Even the expensive ones aren't very pricey.
--------
http://www.crai.archi.fr/RubyLibraryDepot/Ruby/RUBY_Library_Depot.htm
Ruby Library Depot
A library of hundreds of downloadable scripts.
-------
www.sketchucation.com
SketchUcation
A community site that has its own script library. This is a great place to find scripts as they are being developed. The forums are well organized and moderated. You can find a lot of great information here.
--------
http://sketchuptips.blogspot.com/
[Plugin] SketchUp Blog
A blog that keeps on top of new developments in plugins.
--------
http://www.special.eclipse.co.uk/sketchup_training.html

Quarr-IT
A collection of excellent scripts integrated into toolbars and the SketchUp interface.
--------

Rendering Programs:

I'm only including the renderers that work inside of SketchUp. There is a wide range of other programs that can take files exported out of SketchUp.
-----------
http://www.suplugins.com/
Podium
Simple to use program that works inside SketchUp. I've used it and it works quite well.
------------
http://www.light-up.co.uk/
LightUp
Also works inside SketchUp. "Bakes" textures onto the model while using the tool. Fascinating program, when I used it (a couple releases ago) it was a bit difficult to figure out the interface. But it has incredible potential.
------------
http://www.idx-design.com/
IDX Renditioner
I haven't used this one, but it is supposed to be similar to Podium in difficulty and quality of final products.

My portion of the meeting focused on how to install the scripts and where to find them online. Chris Fullmer preceded me with dynamic components and scripts that he put together. His presentation was a show stopper. It was inspiring to see what he's been able to put together in just a few months. Makes me want to spend more time with the program.