Detect units using ruby
-
Hi all,
I'm quite new to Sketchup ruby, and i was wondering is there any way to detect the units being used in a model in ruby?? could be something like model.info.units or something??
-
Look at
model.options
http://code.google.com/apis/sketchup/docs/ourdoc/model.html#optionsOptionsProvider
http://code.google.com/apis/sketchup/docs/ourdoc/optionsprovider.html
OptionsManager
http://code.google.com/apis/sketchup/docs/ourdoc/optionsmanager.htmlRemember to use the keys to access the options as indexes vary from version to version.
To print out all available options for a given version, use this on-liner:
<span class="syntaxdefault"><br />Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">options</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">keys</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">key</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> p key</span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">options</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">key</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">k</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> puts </span><span class="syntaxstring">"> #{k} - #{v}"</span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> </span>
-
@thomthom said:
Look at
model.options
http://code.google.com/apis/sketchup/docs/ourdoc/model.html#optionsOptionsProvider
http://code.google.com/apis/sketchup/docs/ourdoc/optionsprovider.html
OptionsManager
http://code.google.com/apis/sketchup/docs/ourdoc/optionsmanager.htmlRemember to use the keys to access the options as indexes vary from version to version.
To print out all available options for a given version, use this on-liner:
<span class="syntaxdefault"><br />Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">options</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">keys</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">key</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> p key</span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">options</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">key</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">k</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> puts </span><span class="syntaxstring">"> #{k} - #{v}"</span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> </span>
THANK YOU VERY MUCH. it worked
Advertisement