Tuesday, June 30, 2009

9/10ths

I passed the Construction Documents exam. I can sit for the Orals next Spring.

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!