Inputbox issues

Inputbox issues

Postby Pixero » Mon Mar 04, 2019 6:50 pm

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.

Code: Select all
@@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?
0
User avatar
Pixero 
 

Re: Inputbox issues

Postby TIG » Mon Mar 04, 2019 7:03 pm

@@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 !!
1
TIG
User avatar
TIG 
Global Moderator
 

Re: Inputbox issues

Postby Pixero » Mon Mar 04, 2019 7:09 pm

Ah, makes sense. I should have tried that. I just thought that it was like this:
Code: Select all
results = inputbox prompts[0], values[1], "Settings"[2]
0
User avatar
Pixero 
 

Re: Inputbox issues

Postby Pixero » Mon Mar 04, 2019 7:11 pm

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.
0
User avatar
Pixero 
 

Re: Inputbox issues

Postby TIG » Mon Mar 04, 2019 7:38 pm

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 ?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Inputbox issues

Postby Pixero » Mon Mar 04, 2019 7:42 pm

I do it exactly like that and I still get this error:
Code: Select all
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.
0
User avatar
Pixero 
 

Re: Inputbox issues

Postby TIG » Mon Mar 04, 2019 7:46 pm

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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Inputbox issues

Postby Pixero » Mon Mar 04, 2019 8:11 pm

This works but next time the value is in inches.
Code: Select all
@@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?
0
User avatar
Pixero 
 

Re: Inputbox issues

Postby Pixero » Mon Mar 04, 2019 9:13 pm

Solved it this way so I never have to pass the @@depth value to the DC.

Code: Select all
@@depth_inch = @@depth*0.0393700787
0
User avatar
Pixero 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 13 guests

Visit our sponsors: