Get Dimmensions plugin

Get Dimmensions plugin

Postby dedmin » Mon Jun 07, 2010 1:37 pm

Can somebody improve this very useful plugin? When the component is not aligned with the wold coordinates the reported dimensions are not accurate! Thanks in advance!

GetDimensions.rb
0

dedmin 
 

Re: Get Dimmensions plugin

Postby Jim » Mon Jun 07, 2010 2:08 pm

Use .local_bounds instead of .bounds to get the BB in the first place.

boundingBox = model.selection[0].local_bounds

Wait... that doesn't seem to account for scaling... so it's not what I thought.
0
Hi

Jim 
Global Moderator
 

Re: Get Dimmensions plugin

Postby Jim » Mon Jun 07, 2010 3:44 pm

This is based on code from Didier and TIG. It should work for selected Groups and Instances in any context, although I only tried it at model level.



Code: Select all
model = Sketchup.active_model
entities = model.entities
selection = model.selection

e = selection[0]

scale_x = ((Geom::Vector3d.new 1,0,0).transform! e.transformation).length
scale_y = ((Geom::Vector3d.new 0,1,0).transform! e.transformation).length
scale_z = ((Geom::Vector3d.new 0,0,1).transform! e.transformation).length

bb = nil
if e.is_a? Sketchup::Group
  bb = Geom::BoundingBox.new
  e.entities.each {|en| bb.add(en.bounds) }
elsif e.is_a? Sketchup::ComponentInstance
  bb = e.definition.bounds
end

if bb
  width  = bb.width  * scale_x
  depth  = bb.depth  * scale_z
  height = bb.height * scale_y
  puts "#{width}, #{height}, #{depth}"
end
0
Hi

Jim 
Global Moderator
 

Re: Get Dimmensions plugin

Postby dedmin » Mon Jun 07, 2010 4:55 pm

Thanks, but where to put this code? :roll:
0

dedmin 
 

Re: Get Dimmensions plugin

Postby xrok1 » Mon Jun 07, 2010 4:57 pm

could someone post a screen shot of what this plug does? sounds very interesting.
0
“There are three classes of people: those who see. Those who see when they are shown. Those who do not see.”

http://www.Twilightrender.com try it!

xrok1 
 

Re: Get Dimmensions plugin

Postby Jim » Mon Jun 07, 2010 4:58 pm

Just pops a dialog showing the dimensions of the selected Group or Component.
0
Hi

Jim 
Global Moderator
 

Re: Get Dimmensions plugin

Postby dedmin » Mon Jun 07, 2010 5:06 pm

xrok1 wrote:could someone post a screen shot of what this plug does? sounds very interesting.


Untitled.jpg
0

dedmin 
 

Re: Get Dimmensions plugin

Postby xrok1 » Mon Jun 07, 2010 5:35 pm

ahh, bounding box dimensions. :( i was hoping it was some kind of auto dimesioning thing. :oops:
thanks guys.
0
“There are three classes of people: those who see. Those who see when they are shown. Those who do not see.”

http://www.Twilightrender.com try it!

xrok1 
 

Re: Get Dimmensions plugin

Postby Jim » Mon Jun 07, 2010 7:41 pm

I sent a plugin to dedmin to try. It shows the dimensions of a selected group or instance correctly eve when scaled and rotated. I'll post it when I hear back.
0
Hi

Jim 
Global Moderator
 

Re: Get Dimmensions plugin

Postby Jim » Tue Jun 08, 2010 12:21 am

Plugin posted here: viewtopic.php?f=323&t=28851
0
Hi

Jim 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: Google Bot and 11 guests

Visit our sponsors: