sketchucation logo sketchucation
    • Login
    1. Home
    2. Dan Rathbun
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
    Offline
    • Profile
    • Following 0
    • Followers 1
    • Topics 92
    • Posts 4,904
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: Units Strings i18n

      @jim said:

      A dumb question, I think. Of course "Meter" is always "Meter" in any language.

      Actually not, it's 'metre' in French (and I think most of the EU uses that spelling.) But it's still the same unit.

      Link Preview Image
      Metre - Wikipedia

      favicon

      (en.wikipedia.org)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Rendering_options['ForegroundColor'] controls view.draw_text

      I would say this is a bug, as I would have tried using view.drawing_color=

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Units Strings i18n

      @jim said:

      And if so, how do I access them in a language-independent way?
      Update - Ah, by index number?

      YES.

      model = Sketchup.active_model 
       manager = model.options 
       provider = manager['UnitsOptions']
      

      see:
      class OptionsManager
      http://code.google.com/apis/sketchup/docs/ourdoc/optionsmanager.html

      class OptionsProvider
      http://code.google.com/apis/sketchup/docs/ourdoc/optionsprovider.html

      interface OptionsProviderObserver
      http://code.google.com/apis/sketchup/docs/ourdoc/optionsproviderobserver.html

      iterating the members of 'UnitsOptions' gives:

      UnitsOptions Provider
          LengthPrecision ; 4
          LengthFormat ; 1
          LengthUnit ; 0
          LengthSnapEnabled ; true
          LengthSnapLength ; 0.0625
          AnglePrecision ; 1
          AngleSnapEnabled ; true
          SnapAngle ; 15.0
          SuppressUnitsDisplay ; false
          ForceInchDisplay ; false
      
      

      Notice how there are 10 options, and 10 controls in the dialog.

      Also, important, often you must call UI.refresh_inspectors after changing options via Ruby, in order to see the changes reflected in the dialogs. (This is true of the Styles dialog, at least.)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Download to Sketchup button

      @unknownuser said:

      I want my "download to model" button work just like the 3D Warehouse button works..?

      see...

      @unknownuser said:

      http://code.google.com/apis/sketchup/docs/releases.html

      What's new in SketchUp 7.0 M1

      Load Definitions from the Web, or Save to Disk

      • Ability to download a definition from URL
      model.definitions.load_from_url(url, download_handler)
      
      • Ability to Save components to disk from the API
      my_definition.save_as(path)
      

      For more info on DefinitionList.load_from_url (including a prototype download_handler,) see:
      http://code.google.com/apis/sketchup/docs/ourdoc/definitionlist.html#load_from_url

      For info on ComponentDefinition.save_as, see:
      http://code.google.com/apis/sketchup/docs/ourdoc/componentdefinition.html#save_as
      .

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Rendering_options['ForegroundColor'] controls view.draw_text

      @thomthom said:

      This does not update the Edge colour in the viewport. But Sketchup.active_model.rendering_options['ForegroundColor'] value is still updated.

      @ThomThom - I get an immediate change in the displayed edge color when I change rendering_options['ForegroundColor'].

      You didn't turn of your DCs again did ya?

      EDIT - Oh never mind, you mean within a Tool.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Rendering_options['ForegroundColor'] controls view.draw_text

      @thomthom said:

      Typing Sketchup.active_model.rendering_options['ForegroundColor'] = 'pink' into the ruby console changes the edge colours to pink.

      How does this differ from view.drawing_color="pink" ??

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Rendering_options['ForegroundColor'] controls view.draw_text

      @ThomThom, ... last week when I was playing with the RenderingOptions, the controls in the SU dialogs did not reflect my changes until I called UI.refresh_inspectors. (I recall we had a discussion with TIG in the Observers thread, about whether these changes were temporary or permanent; I didn't realize at that time, that the dialogs needed to be refreshed.)

      Regarding view draw changes, remember that ver 7.1 added View.refresh

      .. what's that old saying?
      "Believe nothing that you read, and half of what you see!"

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: IE9 looking good

      Is IE9 gonna install on XP ?

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: WebDialogs - The Lost Manual β€” R1 09 November 2009

      @jim said:

      Would a kind Mac user (or 2) open the Ruby Console, and give the result from entering:

      **$DEBUG**
      The 'Pick-Axe' book says falseis the default.

      @jim said:

      **$VERBOSE** [alias] **$-w**
      The 'Pick-Axe' book says falseis the default and known as 'medium mode'.
      When set to nil, it is 'silent mode'; when set to true, it is 'verbose mode'.

      The reason for the $-w alias 'flag', is that $VERBOSE is [supposed to be] the conditional argument used by warnings. But, something's fishy..

      (from Ruby.h, ver 1.8.6, line 562..564, Language="C" )
      %(#008B8B)[void rb_warning __((const char*, ...)); /* reports if-w' specified /
      void rb_sys_warning __((const char
      , ...)); /* reports if -w' specified */ void rb_warn __((const char*, ...)); /* reports always */]

      So.. rb_warn is NOT supposed to check $VERBOSE, and rb_warning IS.
      What's weird is that the Ruby method Kernel.warn is documented as if it calls rb_warning, instead of rb_warn; and the Core RDoc actually gives two internal examples, one in Pure Ruby (see it) and one in C (see it) that are written to act like rb_warning is supposed to act. (Note, the C example is really named 'rb_warn_m'.)

      But in practice... I find that Kernel.warn acts like rb_warn is supposed to act, and it does not matter what $VERBOSE is set to. The message is always sent to $stderr.

      This has forced me to make my 'warn' calls work the way they should, by doing this:
      # Send warning only if in Verbose mode
      warn('My Informational Message') if $VERBOSE

      # Send warning unless in Silent mode
      warn('My Important Message') unless $VERBOSE.nil?

      # Send warning no matter what Verbose mode
      warn('My Critical Message that MUST be displayed!')

      BUT.. I'm sick of doing this workaround!

      I want to make three warn methods, that work the way they should.
      Firstly, the current warn needs to be renamed old_warn (or something else.)
      And define a replacement warn! that has typechecking, and returns true if no IO error occurs. (The original just returned nil.)
      Then define a new warn, that displays (returns true,) unless in Silent mode (returns false.)
      Third define a new warn?, that checks and only displays if $VERBOSE is true (and returns true, otherwise returns false.)
      (If there's any problem with the $stderr IO object, an Exception should be raised by the object itself.)
      Example Ruby override code: ### under REVISION to a Mix-In Module ###

      
      # file warn_ovr.rb
      
      # Make Warnings work the way they should.
      #
      # by; Dan Rathbun - 16 MAR 2010 - Palm Bay, FL, USA
      #
      # TERMS; Public Domain
      
      module Kernel  ##<<----<<< this will change in next Revision
      
        ### under REVISION to a Mix-In Module with a different module name
      
        # alias the old warn method
        alias_method(;old_warn,;warn)
      
        # warn! will always send to $stderr
        # regardless of $VERBOSE setting
        def warn!(msg)
          unless msg.is_a?(String)
            raise(TypeError,'String argument expected.',caller(1))
          end
          $stderr.write(msg + "\n")
          return true # no IO error occured
        end
      
        # warn will now send to $stderr
        # ONLY if $VERBOSE is not Silent mode (nil)
        def warn(msg)
          unless msg.is_a?(String)
            raise(TypeError,'String argument expected.',caller(1))
          end
          unless $VERBOSE.nil?
            $stderr.write(msg + "\n")
            return true
          else
            return false
          end
        end
      
        # warn? will send to $stderr
        # ONLY if $VERBOSE is in Verbose mode (true)
        def warn?(msg)
          unless msg.is_a?(String)
            raise(TypeError,'String argument expected.',caller(1))
          end
          if $VERBOSE
            $stderr.write(msg + "\n")
            return true
          else
            # We return false if $VERBOSE is nil or false
            return false
          end
        end
      
      end # Kernel
      
      

      EDIT: Code changed.

      • Sketchup has .puts as private, changed to using $stderr.write* cleaned up code a bit; more readable.
        Question, I set raise to remove the last item from the callstack. Not sure if this is correct or not?
      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: WebDialogs - The Lost Manual β€” R1 09 November 2009

      @driven said:

      @Dan #!ruby warn_ovr.rb returns nil
      john

      @John..
      The first line is a boo-boo, should have taken out all of the unix-like load directive. (The file is not meant to run from the command line anyway. It was meant to be a 'require' script.)

      I'm rewriting that now as a Mix-In Module, rather than an override to module Kernel. (Backward compability issues, and so forth.) It would be 'forever' before we would hope to see any changes or additions to the Kernel module anyway, with all the other things they need to fix. (I had to laugh when I saw that Ruby 2.0 was due, or estimated to be complete 01/19/2038.)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Optimization Tips

      @jim said:

      The for loop in Ruby really uses the .each method behind the scenes. ... Although, I can't recall where I learned that.

      'Pick-Axe' > For ... In expressions

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Debugging WebDialogs' .tmp Files

      In a normal MSIE browser window, if an error occurs (and you have Internet Options > "Advanced" (tab) > "Browsing" (group) > "Display a notification about every script error" unchecked,) you will not see a Error Popup, but there wil be an error icon in the lower left corner on the Status bar. Clicking this icon will bringup the Error Popup dialog. If you have Visual Studio installed it will likely ask if you wish to Debug in VS.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Debugging WebDialogs' .tmp Files

      @martinrinehart said:

      "Local Settings" is hidden. Neither your Open File dialog nor Windows Explorer will show it...

      Yes they will. Open Windows Explorer, any folder.
      MENU: Tools > Folder Options
      Choose the View tab.
      Choose 'Show hidden files and folders' under 'Hidden files and folders'

      Other things I do (because I want to see EVERYTHING!)
      I choose:
      check 'Display the contents of system folders'
      check 'Display the full path in the titlebar'
      uncheck 'Hide extensions for known filetypes'
      uncheck 'Hide protected operating system files'

      I can't help it, used PC since DOS first released, and could always see everything... don't like hidden things...
      .. but then I might be a control freak.. πŸ’š

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Sketchup.find_support_file

      Actually Martin.. that example was quick and dirty.

      It CAN be cleaned up. I was thinking it would be better to break out of the iteration when the proper match was found, rather then keep iterating, though how many paths do most people have in their $: anyway?

      You'd likely run a method and set a constant (perhaps Integer index into $LOAD_PATH) and then use that reference from then onward. So it should be a one time, startup type thangy...

      One thing I do is actually put set ENV['SUpath']

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Sketchup.find_support_file

      @jim said:

      Mac use .exe?

      Well.. the point I need to make is.. That Sketchup.find_support_file works best if it has a file to find. In the old days we could not give directories names with .extensions, so we could find dirs with '*.' wildcard. That's not true anymore with 32-bit filesystems.
      He can put a string reference into the method call, and set the reference using a platform conditional statement; sketchup.exe for PC, and whatever it is for Mac.

      @jim said:

      How about using $LOAD_PATH[0]? Is it reliable?

      Not if the user has moved their paths around.

      However.. hmmm... you could always iterate the $LOAD_PATH array, check each element if it includes 'plugins'
      ` target=''
      $LOAD_PATH.each {|e| target=e.dup if e.downcase.include?('plugins')}
      if (not target.empty?) and File.basename(target).downcase=='plugins'

      Plugins target path is good!

      end`

      EDIT: put ( ) around not target.empty? just in case...

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Sketchup.find_support_file

      (1) Only use double-quoted Strings if your:

      • using Regular Expressions (ie: "\n")* doing #{strVar} replacement
        (2) You'll have fewer problems with the interpreter if you get in the habit of putting ( ) around parameters whenever possible, and with NO space between the method name and the (.

      To find the Sketchup folder(directory) try:
      File.dirname(Sketchup.find_support_file('sketchup.exe'))

      Plugins folder, is empty when SU is first installed, so can't test for a file, but, you can append 'plugins' to the above, using File.join which uses File::SEPARATOR between arguments:
      File.join(File.dirname(Sketchup.find_support_file('sketchup.exe')),'plugins')

      Note: Sketchup.find_support_files (plural) on PC returns escaped backslash pathnames, and sometimes returns arrays of pathnames. It's a pain in the butt.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Set path for request dlls

      Most people (who run Su on PC,) already have a copy of Win32API.so where their $LOAD_PATH array can find it, so you should only need to:
      require 'Win32API'
      if it's already loaded, require will skip reloading it.

      You can even get more fancy, by first checking if it's loaded, because it defines the class Win32API, and classnames are constants ie:

      unless (defined? Win32API)=='constant' %(#F0F0F0)[__]require 'Win32API' end

      Also.. I think you must unload those DLLs when your plugin is done with them. Perhaps you might need to use a custom AppObserver implementing the onQuit callback, with your plugin.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: WebDialogs - The Lost Manual β€” R1 09 November 2009

      By the way.. we have no control over C-implemented Ruby objects, that incorrectly call the wrong C 'warn'/'warning' function, ie: don't respond to the setting of $VERBOSE ( called ruby_verbose in C.)

      If you find one, it would need to be reported on RubyForge.net

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Sketchup use of WebKit

      Search topics on WebKit

      Likely Sketchup calls a Safari instance (which uses WebKit.) Can you get Safari to use a particular WebKit build (other than what was released with the last Safari version) ??

      There is also an extra parameter mac_only_use_nswindow, to the WebDialog.new constructor for the Mac ONLY. (I don't know what it's supposed to be about, not having a Mac, other than nswindow is a base window class in Carbon or Cocoa. [Can't remember which.])

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Separating a plugin from others

      @unknownuser said:

      If you check if your plugin has already been loaded with:
      file_loaded?(File.basename(__FILE__))
      from inside of a rbs file - the FILE value == '(eval)' !

      Sounds like File.basename(FILE) is getting set to part of an eval error string.
      I wonder if eval error strings are put to the $! message global?

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • 1
    • 2
    • 232
    • 233
    • 234
    • 235
    • 236
    • 245
    • 246
    • 234 / 246