sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Inputbox issues

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 2 Posters 6.7k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PixeroP Offline
      Pixero
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        @@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 !!

        TIG

        1 Reply Last reply Reply Quote 0
        • PixeroP Offline
          Pixero
          last edited by

          Ah, makes sense. I should have tried that. I just thought that it was like this:

          results = inputbox prompts[0], values[1], "Settings"[2]
          
          1 Reply Last reply Reply Quote 0
          • PixeroP Offline
            Pixero
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              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 ?

              TIG

              1 Reply Last reply Reply Quote 0
              • PixeroP Offline
                Pixero
                last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  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...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • PixeroP Offline
                    Pixero
                    last edited by

                    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?

                    1 Reply Last reply Reply Quote 0
                    • PixeroP Offline
                      Pixero
                      last edited by

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

                      
                      @@depth_inch = @@depth*0.0393700787
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement