Created
May 20, 2010 11:54
-
-
Save watson/407487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sketchup' | |
module MyPlugin | |
class Helper | |
class << self | |
LENGTH_TEXT_SYMBOL_DICT = { | |
:inches => '"', | |
:feet => "'", | |
:millimeters => "mm", | |
:centimeters => "cm", | |
:meters => "m" | |
} | |
LENGTH_NAME_DICT = { | |
:inches => "Inches", | |
:feet => "Feet", | |
:millimeters => "Millimeters", | |
:centimeters => "Centimeters", | |
:meters => "Meters" | |
} | |
def length_type(arg = 'nameString') | |
unitopts = Sketchup.active_model.options['UnitsOptions'] | |
# allow the ordinal in the set to be returned if arg | |
# is any class other than String (or a String subclass.) | |
return unitopts['LengthUnit'] unless arg.kind_of?(String) | |
if unitopts['LengthFormat'] == 0 # decimal | |
unitSet = [:inches, :feet, :millimeters, :centimeters, :meters] | |
unitSet[unitopts['LengthUnit']] | |
elsif unitopts['LengthFormat'] == 2 # engineering | |
:feet | |
else # 1 == Architectural, 3 == Fractional | |
:inches | |
end | |
end | |
def length_text_symbol(arg = 'nameString') | |
LENGTH_TEXT_SYMBOL_DICT[length_type(arg)] | |
end | |
def length_name(arg = 'nameString') | |
LENGTH_NAME_DICT[length_type(arg)] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment