Inputbox issues
-
I have a simple inputbox but I'm getting errors later in the plugin complaining @@depth to be an array so I tried adding a [1] but it doesn't seem to work.
@@depth = 400.mm unless @@depth # Dialog box prompts = ["Depth"] values = [@@depth] results = inputbox prompts, values, "Settings" return if not results @@depth = results[1] #Tried to solve the array error with this. #The Error goes away but the value isn't passed on.
I tried with a:
puts @@depth
but nothing is visible in the console.
Any ideas how to solve this? -
@@depth = results[0]
There's only one input - so the first in the array 'results' is[0]
?
Ruby's array-element counts always start at 0, NOT 1 !
Don't ask why !! -
Ah, makes sense. I should have tried that. I just thought that it was like this:
results = inputbox prompts[0], values[1], "Settings"[2]
-
Your right. It passed the value to puts at least.
But now I'm getting: Error: #<ArgumentError: comparison of Length with nil failed>I'm trying to set an attribute of a DC from this Input box and I guess DC's don't like the .mm thing. Is there any other way of getting the correct lenght as a plain number? From tests that works but it gets translated to inches when returned so it screws up the Input box value the next time it is opened.
-
NO ! Use:
@@depth = 400.mm unless @@depth prompts = ["Depth"] values = [@@depth] results = inputbox(prompts, values, "Settings")
Then if results use:
@@depth = results[0]
??If it's for a DC issue, then try using a float
400.0
in the inputbox and then later on pass it as a value that is converted to inches etc for the DC code ? Later on, when you recover it convert it back ? -
I do it exactly like that and I still get this error:
Error; #<ArgumentError; comparison of Length with nil failed> c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;3220;in `==' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;3220;in `get_cascading_attribute' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;3327;in `get_attribute_value' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;4283;in `parse_reference' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;4809;in `parse_subformula' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;5088;in `block in parse_subformula' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;5085;in `each' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;5085;in `parse_subformula' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;5070;in `block in parse_subformula' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;5067;in `each' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;5067;in `parse_subformula' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;4743;in `parse_formula' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;4483;in `get_formula_result' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;486;in `redraw' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;921;in `block in redraw' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;916;in `each' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;916;in `redraw' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;921;in `block in redraw' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;916;in `each' c;/users/jan/appdata/roaming/sketchup/sketchup 2019/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe;916;in `redraw' ...
Edit: Ok, I'll try that.
-
Skip the inputbox part for initial testing.
Simply set your@@depth
to various 'types' - e.g. float, mm etc, and test each.
Which works ?
That gives you a clue as to which 'type' can be successfully passed... -
This works but next time the value is in inches.
@@wdepth = 400.0 unless @@depth # Dialog box prompts = ["Depth"] values = [@@depth] results = inputbox(prompts, values, "Settings") return if not results @@depth = results[0] @@depth*=0.0393700787
In the last line I turn the mm value into inch so it will be correct in the DC but I need to multiply that value by 2.54 to get it back to mm for the prompt the next time.
Where and how to do that? -
Solved it this way so I never have to pass the @@depth value to the DC.
@@depth_inch = @@depth*0.0393700787
Advertisement