• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

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.
  • P Offline
    pvbuero
    last edited by 30 Jun 2010, 07:55

    Hello,

    I' d like to input a time into my script formated as it's made in the shadowinfo dialog in SU. Is there a way to configure the inputbox to achieve that or how can I make such a dialog ?

    Schatten.png

    Thanks for your help
    Matthias

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 30 Jun 2010, 08:06

      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.

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

      1 Reply Last reply Reply Quote 0
      • D Offline
        Dan Rathbun
        last edited by 1 Jul 2010, 17:47

        @pvbuero said:

        I'd like to input a time into my script formated as it's made in the shadowinfo dialog in SU.

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

        I cannot find and way thru the SU API of determining whether the user wants AM/PM clock or 24 hour clock.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 1 Jul 2010, 18:28

          @dan rathbun said:

          I cannot find and way thru the SU API of determining whether the user wants AM/PM clock or 24 hour clock.

          I guess it's taken from the system locale?

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

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 1 Jul 2010, 19:31

            @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 1 Jul 2010, 20:21

              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
              • D Offline
                Dan Rathbun
                last edited by 1 Jul 2010, 21:07

                @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 3 Jul 2010, 10:13

                  @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
                  • C Offline
                    Chris Fullmer
                    last edited by 3 Jul 2010, 16:14

                    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
                    • D Offline
                      Dan Rathbun
                      last edited by 3 Jul 2010, 19:47

                      @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
                      • D Offline
                        Dan Rathbun
                        last edited by 3 Jul 2010, 21:02

                        @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
                        • D Offline
                          Dan Rathbun
                          last edited by 3 Jul 2010, 21:06

                          @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
                          • T Offline
                            thomthom
                            last edited by 3 Jul 2010, 23:51

                            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 4 Jul 2010, 10:22

                              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 4 Jul 2010, 10:27

                                @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
                                1 / 1
                                • First post
                                  10/15
                                  Last post
                                Buy SketchPlus
                                Buy SUbD
                                Buy WrapR
                                Buy eBook
                                Buy Modelur
                                Buy Vertex Tools
                                Buy SketchCuisine
                                Buy FormFonts

                                Advertisement