When I copy&paste it into the Console then I get the distance between the Camera Eye to the Center of the Boundingbox of the selection.
But when I paste this code into the “Ruby Code Editor” an click on “run” then I get this Error in the Console:
Error: #<ArgumentError: comparison of Length with nil failed>
C:/Users/blablabla/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:270:in ==' C:/Users/blablabla/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:270:in !=’
C:/Users/blablabla/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:270:in block in initialize' SketchUp:1:in call’
There must be some basic understanding I missed.
Does anybody know what I do wrong ?
What version of the as_rubyeditor are you using ?
The EWH version is 3-2.0
That has no == in line #270 - where the error is being noted.
It actually says: r!=nil ? r = r.to_s : r='Nil result (no result returned or run failed)'
Try with the latest version ?
It’s Version 3.2 (at least in “as_rubyeditor.rb” there is that information).
The “About” Screen says something different (I guess this is a mistake by the Author): http://pasteall.org/pic/index.php?id=112058
@I_Alain_I When you post code, or error messages,
it must be wrapped in triple backticks or the forum engine
will swallow the error message (on the first line.)
A workaround in the editor’s code would be to simply check if ‘r’ exists, then otherwise raise an error…
So rather than checking if ‘r’ is not equal to ‘nil’ etc, in the original code: r!=nil ? r=r.to_s : r='Nil result (no result returned or run failed)'
it becomes the less convoluted: r ? r=r.to_s : r='Nil result (no result returned or run failed)'
i.e. when ‘r’ exists at all we turn it into a string, otherwise when ‘r’ doesn’t exist [i.e. it’s ‘nil’ or ‘false’] we make ‘r’ into an error-message string…
@jim_foltz: Thanks, it works. @TIG: I replaced the line you suggested in the Editor’s Code but it returns an Error:
"undefined method `bounds' for nil:NilClass"
Error: #<TypeError: no implicit conversion of NoMethodError into String>
C:/Users/-/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:264:in `+'
C:/Users/-/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:264:in `rescue in block in initialize'
C:/Users/-/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/as_rubyeditor/as_rubyeditor.rb:279:in `block in initialize'
-e:1:in `call'