|
OptionsManager |
Although this is not complex, the documentation as of SketchUp 7.1 does almost nothing to explain what these options are nor how to use these objects. Hence this short appendix.
The OptionsManager class is the gate keeper for a large set of options, which you can easily look up here. This class holds a list of OptionProvider objects. You can index into it by OptionProvider name, this way:
opts = Sketchup.active_model.options op = opts[ "PageOptions" ] # an option provider
OptionProvider objects are a hash where the option name is the key. To continue the above example, op[ "TransitionTime" ] would return 2.0 for the example in the graphic. You can do this in one step:
opts = Sketchup.active_model.options trans_time = opts[ "PageOptions" ][ "TransitionTime" ]
You can do this in one step, but only if you know your provider's name and hash keys. This is a list of all OptionProvider objects names and key/value pairs for my current model:
PageOptions ShowTransition => true TransitionTime => 2.0 SlideshowOptions LoopSlideshow => true SlideTime => 1.0 NamedOptions Print.ComputeSizeFromScale => false Print.FitToPage => false Print.Height => 23.8105583190918 Print.LineWeight => 1.0 Print.NumberOfPages => 3 Print.SizeInModel => 1.0 Print.SizeInPrint => 7.56277084350586 Print.Width => 16.5 Skin.Clean? => Yes Skin.Prep Method => None Skin.Skin Method => By Distance Skin.Smooth? => Unavailible UnitsOptions LengthPrecision => 3 LengthFormat => 1 LengthUnit => 0 LengthSnapEnabled => false LengthSnapLength => 0.125 AnglePrecision => 2 AngleSnapEnabled => true SnapAngle => 15.0 SuppressUnitsDisplay => false ForceInchDisplay => false PrintOptions PrintWidth => 8.5 PrintHeight => 11.0 ComputeSizeFromScale => false SizeInPrint => 1.0 SizeInModel => 1.0 VectorMode => false FitToPage => true NumberOfPages => 1 LineWeight => 0.5 PixelsPerInch => 150.0 SectionSlice => false ModelExtents => true PrintQuality => 0 ScaleAdjustment => 1.0 QualityAdjustment => 1.0
And here's a tiny program you can run to get the same info for your own models:
require "sketchup"
opts = Sketchup.active_model.options
for provider in opts
puts provider.name()
for key, val in provider
puts "\t" + key + " => " + val.to_s()
end
end
|
|