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: New API doc - typos and questions

      Model.get_product_family
      http://code.google.com/apis/sketchup/docs/ourdoc/model.html#get_product_family

      @unknownuser said:

      Returns a constant number which indicates the product family of the installed SketchUp application.

      This is an Application related attribute, why is it part of the Model class?

      This should be a method of the Sketchup module as in: Sketchup.get_product_family
      _

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: New API doc - typos and questions

      @thomthom said:

      @jim said:

      Oh, I think there is a completely undocumented UTM class in there somewhere under Geom.

      hm.. all I can find out about that one is:
      Geom::UTM.instance_methods.sort.join("\n")... snip ...

      from Wikipedia search on "UTM":
      Universal Transverse Mercator coordinate system, a grid-based method of mapping locations on the surface of the Earth.
      http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system
      _

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: HLR.parent BUG SPLAT!

      @thomthom said:

      When do you ever get an HLS class anyway?

      You can make one using: var = Sketchup::HLR.new

      But as I had said in the API forum:this post

      @dan rathbun said:

      The classSketchup::HLR is undocumented in the API.

      It's an Entity subclass.
      It inherits all the Entity baseclass methods, and adds 2 of it's own:

      • .calculate* .num_faces

      If you create a HLR object at the console, and call .parent (when it has no parent) a BUG SPLAT! results. See post: (link to this Bug Reports thread.)

      What is this class HLR used for? (.. as there is no .add_HLR method for the Entities collection object.)

      The HLR question remains unanswered...
      _

      posted in SketchUp Bug Reporting
      Dan RathbunD
      Dan Rathbun
    • RE: Observers WhishList

      _
      Sketchup::SelectionObserver

      This observer needs fixing! I would put this in the high priority group.

      Per ThomThom's Observer Review "State of Observers"
      http://forums.sketchucation.com/viewtopic.php?f=180&t=20676&start=0#p173630

      Sketchup::SelectionObserver

      .onSelectionAddednever triggers
      .onSelectionRemovednever triggers.

      Instead,
      .onSelectionBulkChangeand .onSelectionClearedalways triggers.
      _

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: New API doc - typos and questions

      Model.add_note

      The note is not displayed unless there are entities in the model. If you add a note first thing in a new model, it is invisible but .visible? on the note object still returns true.

      As soon as you draw something, the note appears.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: View.pickhelper

      @thomthom said:

      View.pick_helper
      http://code.google.com/apis/sketchup/docs/ourdoc/view.html#pick_helper

      @unknownuser said:

      If you supply x and y, they are screen coordinates of the point at which you want to do a pick. Typically, there will be points that were passed to a method on a tool class.

      From that I'm given the impression that I can do:
      ip = view.pick_helper(x, y)
      And it'd then return a PickHelper that's picked a point.
      But that does not seem to work.

      The API should probably say "If you supply x and y, they are screen coordinates of the point at which you will want to do a pick." (refering to the pick as a future event, yet to occur.)

      @thomthom said:

      If I do this:
      ip = view.pick_helper ip.do_pick(x, y)
      Then it works.

      Because the description of PickHelper.do_pick states: "The do_pickmethod is used to perform the initial pick."
      So, prior to this method getting called, the picklist should always be empty; and PickHelper.count should return 0.

      @thomthom said:

      Bug?

      YES bug.

      I think it either may have once worked and because of changes it no longer does, OR it was intended to work, but when the code for PickHelper class was written it wasn't possible, or someone forget the intention, etc. (perhaps more than one person was working on it and things got lost in the shuffle.)

      What is supposed to happen when you call:
      ph = view.pick_helper(x,y,apt) ?
      I think something like this:

      
      class Sketchup;;View
        def pick_helper(*args)
          case args.size
          when 0
            Sketchup;;PickHelper.new()
          when 1
            raise ArgumentError,"x and y required", caller
          else
            Sketchup;;PickHelper.new().init(args)
          end
        end#def
      end#class
      
      

      @thomthom said:

      • then what's the point of the arguments in the view_pickhelper method?

      So the arguments for View.pick_helper were really 'intended' to be passed to PickHelper.init, so that you could then use either PickHelper.test_point or PickHelper.do_pick without having to again specify the x,y. Any method that takes an apeture would also use either the one set by .init or (as we are told in the API,) the "standard Sketchup aperture size".

      However, PickHelper.do_pick always requires the two x,y arguments (regardless of whether .init was first called.)

      And PickHelper.test_point, I cannot get to return true (regardless of whether .init was first called, or all arguments are specified.) Even when the point argument is exactly the same as the x,y .. still .test_point returns false.

      p3.test_point [200,200],200,200,20
      >> false
      

      _

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Webdialog] onresize firing twice

      (Discusssing Javascript not ruby!)

      Just thinking about this a bit...

      (1) In order to resize the window, the user must move the mouse OUTSIDE the BODY or DOCUMENT, which fires the onmouseleave event for those Elements.

      (2) The onresize event fires (perhaps multiple times,) during user sizing. So just set a wasResized flag from 0 to 1 when the event fires. You don't care how many times the flag is set to 1.

      (3) The user (usually) moves the mouse back into the element, and the onmouseenter event fires. So perhaps in BODY onmouseenter handler, check wasResized, if 1, then reset to 0 and call your layout resize/relayout function.

      The question is does Safari also implement onmouseenter ??

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Webdialog] onresize firing twice

      @chrisglasier said:

      @dan rathbun said:

      onresizeend

      I did have a look at that. It seems it's for changing the dimensions of the object in a control selection whatever that is. The name is confusing.

      It has to do with editable content (like a wikipage) which is not what you want. And besides, the phrase "There is no public standard that applies to this event." means it's NOT in the W3C HTML/DHTML spec. It's a MS invention, and may only work in MSIE. (Although, some of those pages on MSDN are out of date.)

      So that kills cross-platform unless Safari also implements the feature.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • DC Toolbar slowing Sketchup?

      DC Toolbar slowing Sketchup?

      I have noticed that if the DC Toolbar is ON (visible) the third button, with tooltip: "Component Attributes (Pro Only)" continously calls Sketchup.is_pro? to decide whether it should be grayed (on free version,) or colored/active (for pro version.) It's even worse (happens more often,) if you move the mouse.

      Seems to me, the "pro check" should either be done at toolbar definition and omit the 'pro' button for the free version, OR the check should be done after the user clicks the button. If pro, it does it's thing, if Free it would pop up a 'Sorry Charlie' messagebox (with a link to buy Pro of course.)

      But to dog-down the application just to decide whether to paint 1 button is <insert your own explicatives and adjectives here>.

      So heads up on this. You may wish to have that toolbar off when not doing DC work.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Webdialog] onresize firing twice

      onresizeend
      http://msdn.microsoft.com/en-us/library/ms536960(VS.85).aspx

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Support for data serialization formats

      @dan rathbun said:

      @richmorin said:

      I have a bunch of configuration data that I want to serialize, write to a file, and have my plugin load.

      Suggestions, anyone?

      The 3rd, option is to use the Sketchup.write_defaultand Sketchup.read_defaultmethods to store your plugin options in the Windows Registry (win32) or Plist file (Mac).

      • Con here is that your options must be 'flatfile' data. No multi-level data is allowed.

      Actually not entirely true.

      You can set up the text fields of your attributes anyway you wish, since it's your plugin that will use them.

      If it's easier, and faster for loading.. you can have 'array' fields.
      ie, a single attribute value can actually be a CSV list of multiple values. (You can use whatever delimiter you wish, not just comma.)

      del = '%' # delimiter 
      valListString = arrayOfValues.join(del) 
      # then assign valListString to attribute value 
      
      # reading is opposite 
      # assign attribute value to valListString 
      arrayOfValues = valListString.split(del) 
      # you'd need to iterate the array and convert 
      # any number strings to numerics 
      # see the Sketchup extenstion String.to_l
      

      Sketchup extenstion String.to_l

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Support for data serialization formats

      page on class PStore
      http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_standard.html#PStore.new
      then scroll up to top of PStore section

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Support for data serialization formats

      @richmorin said:

      I have a bunch of configuration data that I want to serialize, write to a file, and have my plugin load.

      Suggestions, anyone?

      You could do with a Hash as it's done in 'rbconfig.rb', (or better yet an OpenStruct,) and have your plugin require it's 'plugcfg.rb' file. But this is only good if the configuration options always will be the same when your plugin starts up.

      If they will change depending on user choices, etc. then a PStore might be the answer.

      Both 'ostruct.rb' and 'pstore.rb' are located in the standard lib directory.
      Con with PStore, it has other file dependencies. Your Users would need a full Ruby installation.
      OpenStruct objects only need 'ostruct.rb' (it's basically a Hash that has automatic attribute accessor generation.) So you could put a copy of 'ostruct.rb' in your plugin's code subdir, and use it IF the user did not have a full ruby install.

      The 3rd, option is to use the Sketchup.write_defaultand Sketchup.read_defaultmethods to store your plugin options in the Windows Registry (win32) or Plist file (Mac). Con here is that your options must be 'flatfile' data. No multi-level data is allowed.
      All you have is the KEY for your plugin, and a list of Attributes (and their) values under the Key. Pro is you can read from and write to the attributes any time you wish. (Strongly suggest any keyname begin with "Plugin_" and NO spaces in keyname!)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Support for data serialization formats

      Another thing, find the rbconfig.rb file, and read it, or run it and then look at the RbConfig::CONFIG hash. It has all the paths to the proper libs in it for your platform.

      The 'rbconfig.rb' file should be in the platform sub-dir of the standard library dir.

      You might even check if the file has already been loaded by:
      defined? RbConfig::CONFIG
      at the console.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Support for data serialization formats

      @richmorin said:

      My initial plan was to use YAML for this, but I don't have a clear idea of how to get the YAML libraries to load (on a Mac Pro). I tried the following, but it causes SU to crash:
      I'd suggest having require search the standard libs first, then vendor libs, and lastly the site libs. (But if you want extensions to be able to override the standards, well the the opposite order may be the thing for you. For instance you may have a custom 'yaml.rb' in your site lib, that you wish to be loaded instead of the 'yaml.rb' in the standard lib.)

      The standard 'yaml.rb' file should be located in the standard ruby library directory. Check manually that it is actually there.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Hiding Outliner Window

      At the end of the operation, does SU update the UI automatically?

      or, is it a good idea (just to be sure) to call:
      UI.refresh_inspectors # force complete UI update
      http://code.google.com/apis/sketchup/docs/releases.html

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: New API doc - typos and questions

      @thomthom said:

      Yea - I tested it later that day. It's what the Geom module describes as a line.

      Shouldn't the API have a definition for Line and/or Ray as a class (under the Geom module) ?

      something like:

      
      class Geom;;Ray < Array
        def new(*args)
          Array[Geom;;Point3d().new, Geom;;Vector3d().new]
          super()
        end
      end
      
      
      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: New API doc - typos and questions

      @thomthom said:

      View.pickray
      http://code.google.com/apis/sketchup/docs/ourdoc/view.html#pickray

      @unknownuser said:

      Returns:
      ray a ray

      "a ray"? Without testing this I#m guessing either a vector or line.

      see this...

      @unknownuser said:

      Model.raytest
      A ray is a two element array containing a point and a vector [Geom::Point3d(), Geom::Vector3d()]. http://code.google.com/apis/sketchup/docs/ourdoc/model.html#raytest
      _

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Observers WhishList

      _
      I've noticed there does not seem to be Observers for classes:

      • Importer* Exporter* TextureWriter
        Anyone think there's any need here?
        _
      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: New API doc - typos and questions

      _
      Model.title

      @unknownuser said:

      The tile method retrieves the name of the model. If the model is saved on disk, returns the file name without extension. Otherwise returns an empty string.
      http://code.google.com/apis/sketchup/docs/ourdoc/model.html#title
      Change 'tile' to 'title' in method description.

      We could use Model.is_saved? and Model.is_unsaved? methods, as the Model.title method is the only way (that I can find) to determine if the model has yet been saved or not. We cannot rely upon the word 'Untitled' (in the caption bar) because that may actually be a valid filename.

      Workaround:

      
      class Sketchup;;Model
      def is_saved?
        return not title.empty?
      end
      def is_unsaved?
        return title.empty?
      end
      end # class
      
      

      _

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • 1 / 1