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

    How to input a time ?

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 4 Posters 1.4k Views 4 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      @pvbuero said:

      I'd like to input a time into my script formatted as it's made in the shadowinfo dialog in SU.
      [floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs]
      http://forums.sketchucation.com/download/file.php?id=50453

      [floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs][floatl:12wnmvbs][/floatl:12wnmvbs]Schatten.png
      Is there a way to configure the inputbox to achieve that or how can I make such a dialog ?

      If your asking about slider, textbox and spinner controls all linked together, then ThomThom is correct. You either must make a WebDialog, or use wxSU (wxWidgets,) but going the wx route requires your users to have wxSU installed. (I'm also not sure if wx works well on the Mac.)

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • P Offline
        pvbuero
        last edited by

        Hi Dan,

        thank's a lot for your help.

        @unknownuser said:

        Interesting! I just noticed that you have your time set to display the 24 hour clock.

        I think that's because I use the german SU Version and we usually use a 24 hour clock here.

        I 'll try to understand your code as an exercise but I' ve already begun to read the webdialogs chapter in Automatic SketchUp... I'm curious where that leads me to. πŸ˜•

        Matthias

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          @pvbuero said:

          I've already begun to read the webdialogs chapter in Automatic SketchUp... I'm curious where that leads me to. πŸ˜•

          Don't forget ThomThom's WebDialogs - The Lost Manual topic
          .... or download the The PDF version.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • P Offline
            pvbuero
            last edited by

            @thomthom said:

            You'd have to make a webdialog. I'd recommend using a framework, like jQuery that make thing much easier. jQuery has UI plugin widgets that let you easily add the UI gadgets you need.

            Sigh... I now know how sketchup functions can be called by a webdialog. I played a little with the example in chapter 13 of automatic sketchup...
            But now back to my objective: I simply want to input a time with a webdialog. I googled timepicker jquery and found that.
            But I've no idea how I can use that tool. Where to find the variable with the time ? where must the "window.location = 'skp:...." command be placed ? ...
            Seems to me I have to learn jquery first, but therefore I need to learn javascript first 😞
            Well .. I didn't want to learn all languages available, I just want to input a time (and learn ruby for sketchup πŸ˜„ )

            Is there a little tutorial or something to make the first step using jquery UI plugins a litte easier ?

            As always .. thanks a lot for your help.
            Matthias

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              Maybe I give up too easily, but I've completely quit trying to use web dialogs. It seems the pro's have big headaches trying to implement them smoothly. So a beginner like doesn't stand a chance. It was VERY overwhelming to try to learn HTML, javascript, and css all at once. Then people keep mentiong jquery and these other development packages to use. That is just another layer of complexity that make webdialogs very innaccesible for a beginner.

              I've had quite a few scripts have to be more simple in scope because I couldn't make a user interface for them. I've recently found some great workarounds using the view.draw commands. But they are still not quite as versatil as they could be for UI making. And the WxSU package still seems to be buggy, and requires a separate installtion by the user. So its a good alternative, but not really great.

              So as painful as it may be, you might just consider forcing the user input to be done through the built in SU input window.

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @pvbuero said:

                Is there a way to configure the inputbox to achieve that ...

                I think you are refering to UI.inputbox() and it's nasty habit of not not allowing anything other than a decimal point mixed with numerals.

                But you could use a string. And then parse the string afterward.

                
                @hour=13
                @min=30
                @timeStr=@hour.to_s<<';'<<@min.to_s
                getTime=true
                if getTime
                  result = UI.inputbox(['Time'],[@timeStr],'enter Time')
                  #result = UI.inputbox(['Time'],[@timeStr],'eintreten Uhrzeit') 
                  unless result.false?
                    if result.include?(';')
                      @hour=result[0].split(';')[0].to_i # stunde/uhr
                      @min=result[0].split(';')[1].to_i  # winzig
                    end
                    if @hour.between?(0,23) && @min.between?(0,59)
                        getTime=false
                    end
                    if getTime
                      # invalid time string
                      ret = UI.messagebox('Invalid Time !',MB_RETRYCANCEL)
                      #ret = UI.messagebox('Invalide Uhrzeit !',MB_RETRYCANCEL)
                      getTime=false unless ret==4
                    end
                  else
                    # user cancelled the dialog
                    getTime=false
                  end
                  retry if getTime
                end
                end #mod
                end #mod
                
                

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @pvbuero said:

                  Where to find the variable with the time ?

                      def get_shadow_time
                        model = Sketchup.active_model 
                        shadowinfo = model.shadow_info
                        shadtime = shadowinfo['ShadowTime']
                        # shadtime is a Time class object
                      end
                  
                  
                  • Ruby Time class from the 'Pick-Axe' book.
                  • Time class in Ruby Core Docs.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @pvbuero said:

                    I didn't want to learn all languages available, I just want to input a time (and learn ruby for sketchup ... )

                    You never were clear on whether it was sliders and spinner controls that you desired, or just a plain ol' entry box. ??

                    Did you try the example I posted above? (It does need to be adjusted for the bug in the Shadow Time returned by Sketchup. And I didn't test it.)
                    EDIT: I did fix an error (because the inputbox returns false if the user cancels,) I changed:
                    unless result.nil?
                    to:
                    unless result.false?

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      Yes, one do need to understand tha basics of HTML and javacscript before taking on a framework that builds upon it.

                      What is your task? A window with a slider where you can define a time of the day?

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • P Offline
                        pvbuero
                        last edited by

                        Hi,

                        had to pause a little with ruby and watch the soccer match πŸ˜‰

                        @unknownuser said:

                        You never were clear on whether it was sliders and spinner controls that you desired, or just a plain ol' entry box. ??

                        It not necessarily needs to be a slider. I do this little project just for fun and to learn how to use ruby.
                        As I'm always nosy for new things I wanted to know how user interfaces can be made in SU.
                        Now I know something about the different approaches and I also know that it takes a lot more effort to understand and use webdialogs than just configuring little predefined parts...

                        For now I'm satisfied with Dan's script. Thank you for that...
                        Matthias

                        1 Reply Last reply Reply Quote 0
                        • P Offline
                          pvbuero
                          last edited by

                          @dan rathbun said:

                          @pvbuero said:

                          Where to find the variable with the time ?

                              def get_shadow_time
                          >       model = Sketchup.active_model 
                          >       shadowinfo = model.shadow_info
                          >       shadtime = shadowinfo['ShadowTime']
                          >       # shadtime is a Time class object
                          >     end
                          > 
                          
                          • Ruby Time class from the 'Pick-Axe' book.
                          • Time class in Ruby Core Docs.

                          I didn't mean in SU. I meant "variable with the time" in the javascript file ...
                          But I think that's to much new stuff at once.

                          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