sketchucation logo sketchucation
    • Login
    1. Home
    2. Chiefwoodworker
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 26
    • Posts 151
    • Groups 1

    Chiefwoodworker

    @Chiefwoodworker

    10
    Reputation
    1
    Profile views
    151
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Chiefwoodworker Unfollow Follow
    registered-users

    Latest posts made by Chiefwoodworker

    • Sketchup class load method

      Hi guys,

      I believe there may be a bug (or incorrect implementation) with the Sketchup class load method. My understanding of the Sketchup class load method is that it is modeled after the Ruby Kernel load method but designed to handle scrambled files (.rbs) as well as non-scrambled files (.rb). The problem is that it doesn't seem to behave the same in that the Kernel.load method will load a .rb file even if it is already loaded - with the appropriate warnings - wereas the Sketchup.load method does not; even when executed from the Ruby console.

      For example:

      Kernel.load 'cabwriter_factory_settings.rb' results in

      C:/Users/Joe/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/cabwriter_factory_settings.rb:17: warning: already initialized constant CabWriterFactoryInitialize::NEW_PROJECT
      C:/Users/Joe/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/cabwriter_factory_settings.rb:17: warning: previous definition of NEW_PROJECT was here
      true

      Whereas Sketchup.load 'cabwriter_factory_settings' results in

      false

      Am I missing something or is this a bug?

      posted in SketchUp Bug Reporting sketchup
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @driven said:

      @thomthom said:

      What should "1w" represent?

      chosen at random, maybe 1*width or 1 womble
      john

      I'm with you John. I calculate all my dimensions in wombles.

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @tig said:

      Why not take your normal 'numbers' text as your lengths, and then use key-down checks for toggling what it means ?
      Like Cmd/Ctrl, Shift etc *** - so on one press of that key it expects one type of value [shown in status-bar] on the next press it's something else = i.e. it's a 'toggle'.

      ***You can use TAB key action as a toggle BUT it must be key-up as the MAC doesn't recognize tab-down - only tab-up !

      Hi TIG,

      That is exactly what I will end up doing in my tool. So as far as I am concerned I have a solution to the problem I raised, thanks to the folks like you who responded to my original question.

      However, I think the bigger issue here is that there are scripts in this thread that work on the Mac and not the PC, and scripts that work on the PC and not the Mac. Apparently the Mac is not aware of the String class to_l method and the PC doesn't handle the h shortcut key correctly. Although I would argue that the PC is handling the h shortcut key the way I would like it to and the PC and Mac are handling shortcut keys when they shouldn't be if the VCB is active for user input.

      I for one just wish that release 2013 spent more time on bug fixes, platform inconsistencies and Ruby API maintenance than it did on icon changes which are driving me nuts and causing me a lot of work.

      But again, thank you and the others who helped me on this issue.

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @chiefwoodworker said:

      But your code is clearly more correct and you may have saved me a Mac bug. Very interesting that it works on the PC but not the Mac.

      Whoops! Let me correct myself. SketchUp has a String def called to_l so the you don't need the to_f. Are you sure it doesn't work without the to_f?

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @driven said:

      Hi Joe,
      your script partially works on mac with to_f added @ line 4.

      Interesting John. On my Windows PC I modified the script as follows:

      <span class="syntaxdefault">def onUserText</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">text</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> view</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Text is a #{text.class} class."</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    begin<br />      value </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> text</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_l<br />      puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Value is a #{value.class} class."</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    rescue<br />      </span><span class="syntaxcomment"># Error parsing the text<br /></span><span class="syntaxdefault">      UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">beep<br />      puts </span><span class="syntaxstring">"Cannot convert #{text} to a Length"<br /></span><span class="syntaxdefault">      value </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> nil<br />      Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">set_status_text </span><span class="syntaxstring">""</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> SB_VCB_VALUE<br />    end<br />    return if </span><span class="syntaxkeyword">!</span><span class="syntaxdefault">value<br />    if </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">state </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> 1 and </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">stick_pt2</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">valid</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault">      build_story_stick</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">true</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> value</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">      new_stick<br />    end<br />  end</span>
      

      and get the following puts to the console. No complaints of coercing String to Length.

      Text is a String class.
      Value is a Length class.

      But your code is clearly more correct and you may have saved me a Mac bug. Very interesting that it works on the PC but not the Mac.

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @thomthom said:

      I looked further at the behaviour of the Tool class - using variations of this snippet to inspect the behaviour:

      thomthom,

      Your help is well above and beyond anything I could ask for. Thanks again. I am loading the snippet to complete the "etc" and see if there are keys I can use.

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @thomthom said:

      I asked the SketchUp team, and they confirmed that onUserText enables the VCB - and enableVCB? is there to let you disable the VCB when you do not want user input. (For instance - if your tool uses the VCB to adjust values then you don't want the VCB to be enabled until you have performed an action.)

      And enableVCB? is queried on certain event which one can assume the tool changes state - such as on mouse clicks.

      thomthom,

      Thanks very much for the help on this and clearing things up. The documentation on this is really poor and misleading. I still wish we had a way to disable shortcut keys like the native tools have.

      Thanks again.

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @thomthom said:

      It's only a simple property to enable or disable the VCB.
      The docs only says:

      The enableVCB? method is used to tell SketchUp whether to allow the user to enter text into the VCB (value control box, aka the "measurements" panel). If you do not implement this method, then the vcb is disabled by default.
      

      So it doesn't affect what types of characters you can input - it just enables/disables the control as a whole.

      I don't think it is the onUserText that is enabling the VCB. I think the default is true, not false. Try this script:

      class MyTool def enableVCB? UI.beep end end; Sketchup.active_model.select_tool( MyTool.new )

      Depress and release the left mouse button slowly. You will see that enableVCB? is called on both the down and up of the left mouse button. That's why I think it is intended to sample each key stroke, to see if a shortcut key was preceded by a number, in which case it would be interpreted as a parameter of the number and not a shortcut key. But it doesn't get called at all with a key stroke, including the Enter key, which I think is the bug. Why is it called with a mouse action? That's what's curious to me.

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @tig said:

      It doesn't exist...
      Just made it up - from what I know works... 😉

      I like your style 😉

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker
    • RE: VCB and Shortcut Keys

      @tig said:

      The excepted characters that are OK after a number are:
      ",',m,mm,cm,s,x,/,*,[,],<,> etc
      Can you use some of those in your custom inputs...

      TIG,

      Where in the documentation did you find this list of accepted characters after a numeral? I haven't been able to locate it.

      posted in Developers' Forum
      ChiefwoodworkerC
      Chiefwoodworker