#----------------------------------------------------------------------------- # # Copyright 2005, CptanPanic # # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # #----------------------------------------------------------------------------- # Name : GetDimensions.rb # Type : Tool # Description : Displays Dimensions of Component. # Menu Item : Plugins -> Get Component Dimensions. # Context-Menu: None # Author : CptanPanic # Usage : Select Component, and call script. # Date : December 2005 # Version : 1.0 Initial Release. # #----------------------------------------------------------------------------- require 'sketchup.rb' def get_dimensions model = Sketchup.active_model ### start undo... model.start_operation "undo" entities = model.entities mname = model.title ### show VCB and status info... Sketchup::set_status_text(("GET COMPONENT DIMENSIONS..." ), SB_PROMPT) Sketchup::set_status_text(" ", SB_VCB_LABEL) Sketchup::set_status_text(" ", SB_VCB_VALUE) ### Get Selected Entities. boundingBox = model.selection[0].bounds ### If no more than one component is selected popup dialog stating size. dims = [ boundingBox.height, boundingBox.width, boundingBox.depth ] dims.sort! UI.messagebox("Thickness: " + dims[0].to_s + "\nWidth: " + dims[1].to_s + "\nLength: " + dims[2].to_s) ### commit undo... model.commit_operation end ### do menu if( not file_loaded?("GetDimensions.rb") ) add_separator_to_menu("Plugins") UI.menu("Plugins").add_item("Get Dimensions") { get_dimensions } end#if file_loaded("GetDimensions.rb")