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

    Get the Click-Style via the Ruby API?

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 5 Posters 632 Views 5 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

      @thomthom said:

      Get the Click-Style via the Ruby API? How?

      Registry

      key: HKCU\Software\Google\Sketchup7\Preferences

      Preferences dialog > Drawing tab (page)

      att: ClickStyle

      • Click-drag-release = 0* Auto Detect = 2* Click-move-click = 1
        att: ContinueLineMode

      • (boolean) 0 | 1
        att: DisplayCrosshairs

      • (boolean) 0 | 1

      @thomthom said:

      Oh no - not another inaccessible property...

      Sorry.. yes they are all DWORD values.
      As you know by now... read_default and write_default cannot read**|**write DWORD values.

      p Sketchup.read_default('Preferences','ClickStyle','Read Error!')
      >> "Read Error!"
      

      The only GOOD thing is the values appear to be dynamic (ie, they are updated in the registry when the dialog is closed and NOT when Sketchup shuts down. However.. changing pages in the Preferences dialog does not update the registry value, only when the whole dialog is closed.)

      I'm not here much anymore.

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

        Best I can do then is just mimic the default setting "Auto-Detect". sigh Another item for the wish-list.

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

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

          @thomthom said:

          Best I can do then is just mimic the default setting "Auto-Detect".

          Does the above code snippet work on the Mac ??

          If YES, then for Windows you have 3 options:

          1. A shell command (or IO.popen,) calling reg.exe, with the key/attribute as args1. use the standard Ruby library Registry1. use a Win32 System call via Win32API.so

          I'm not here much anymore.

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

            @dan rathbun said:

            Does the above code snippet work on the Mac ??

            hm.. dunno. will have to test.

            @dan rathbun said:

            A shell command (or IO.popen,) calling reg.exe, with the key/attribute as args

            This can be done via the SketchUp Ruby? I don't want to bundle another library just to read this setting.

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

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

              @thomthom said:

              @dan rathbun said:

              A shell command (or IO.popen,) calling reg.exe, with the key/attribute as args

              This can be done via the SketchUp Ruby?

              
              unless defined? Platform require 'Platform' # Platform.rb
              if Platform.is_win?
                clickstylecmd ='REG QUERY HKCU\Software\Google\Sketchup7\Preferences /v ClickStyle'
                num=nil
                IO.popen(clickstylecmd) { |f| num=("%x" % f.readlines[4].split(' ').last).to_i }
              elsif Platform.is_mac?
                num = Sketchup.read_default('Preferences','ClickStyle','Read Error!')
              else
                # error unsupported platform
              end
              # detect ClickStyle setting
              unless num=='Read Error!'
                if num==0
                  # Click-drag-release
                elsif num==1
                  # Click-move-click 
                elsif num==2
                  # Auto Detect 
                else
                  # error
                end
              else
                # raise an exception
              end
              #
              
              

              There is an annoyance.. a cmd window flashes on the screen but disappears.

              I'm not here much anymore.

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

                @dan rathbun said:

                There is an annoyance.. a cmd window flashes on the screen but disappears.

                Ah - and that can not be suppressed?

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

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

                  @thomthom said:

                  @dan rathbun said:

                  There is an annoyance.. a cmd window flashes on the screen but disappears.

                  Ah - and that can not be suppressed?

                  I haven't yet found a way.
                  maybe with a PIF file we can make it run minimized ?

                  I'm not here much anymore.

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

                    And BTW shell commands are done with Kernel.` (backquote character)
                    see http://phrogz.net/ProgrammingRuby/ref_m_kernel.html#Kernel._bq

                    I'm not here much anymore.

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

                      @dan rathbun said:

                      And BTW shell commands are done with Kernel.` (backquote character)
                      see http://phrogz.net/ProgrammingRuby/ref_m_kernel.html#Kernel._bq

                      More Info: The shell execution also sets the $? variable with the command's exit status.

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • L Offline
                        lionk
                        last edited by

                        @dan rathbun said:

                        And BTW shell commands are done with Kernel.` (backquote character)
                        see http://phrogz.net/ProgrammingRuby/ref_m_kernel.html#Kernel._bq

                        still a cmd window...
                        ex:ipconfig /all

                        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