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
    • Redefine Thumbnail on Save (Control)

      Not a 'working BUG' per se, but it's seems IMHO, a design bug.

      The 'Redefine Thumbnail on Save' control checkbox is in an unnatural location (at least in my opinion.) It is currently on the 'File' page, of the 'Model Info' ToolDialog (beneath the 'Description' textarea.)

      This space could be better used for text input controls for the Model.name and Model.tags attributes (which it seems can currently only be set thru rubyscript.)

      It would be better (or more natural) if the 'Redefine Thumbnail(s) on Save' checkbox, was located on the 'General' page, in the 'Saving' section, of the 'Preferences' Dialog (ie: it would/should be a global setting for all models.)

      OK posted two threads in Wishlist forums for discussion:

      • Model.name/Model.tags:
        "Re: skp file format to carry keywords (tags)"
      • Redefine Thumbnail Checkbox location
        "Thumbnail Checkbox ..."
      posted in SketchUp Bug Reporting sketchup
      Dan RathbunD
      Dan Rathbun
    • RE: WxWindows for SketchUp Dialogs

      @unknownuser said:

      Why Sketchup.active_model.name returns always an empty string.

      ANSWER: It doesn't ALWAYS return an empty String, it always returns the value of the name attribute (which is class String.)

      But IF you never set the value of the name attribute, then of course it will 'seem' to always be an empty value, because it is.

      The value can be set easily using the Model.name= method.

      Example Code:

      
      n = Sketchup.active_model.name
      n.inspect
      #>> ""
      Sketchup.active_model.name="A newly set name for my model."
      n.inspect
      #>> "A newly set name for my model."
      
      

      IF you are writing plugins for other users, you should not expect the name attribute to always be empty, and should (in your code,) allow for those times when the model has been assigned a name value (by the user or another plugin.)

      ALSO, in the Outliner Window, the model will be listed by .title value, NOT by the .name attribute.

      P.S.: I can't find a edit control, anywhere in the UI that allows setting the .name (or the .tags) attribute. They SHOULD be on the 'File' page of the Model Info ToolDialog, but are not. (This forces us to use the Console to set the name or write a lil' script to make an inputbox.)

      Edited: meant to say ' .tags' attribute instead of '.note'; a note is just a Text class object, and not a attribute of the Model.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: WxWindows for SketchUp Dialogs

      @thomthom said:

      @dan rathbun said:

      The Model.title method returns the basename (ie filename,) minus the file extension.

      Uh? is that something SU implements? don't see it in the manual...

      Woops.. sorry omitted the link. Here is is:
      http://code.google.com/apis/sketchup/docs/ourdoc/model.html#title

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • STD IO .isatty produces BUG SPLAT!s

      The following simple boolean methods produce a Sketchup BUG SPLAT!, instead of returning true or false:

      **$stdin.isatty STDIN.isatty STDOUT.isatty STDERR.isatty**

      Platform: Win32
      BUG SPLAT! reports sent

      posted in SketchUp Bug Reporting sketchup
      Dan RathbunD
      Dan Rathbun
    • RE: WxWindows for SketchUp Dialogs

      @unknownuser said:

      model_name=File.basename(model_path,".skp")
      

      was model_name=File.basename(model_path) which was including extension of a SU file.

      The Model.title method returns the basename (ie filename,) minus the file extension.

      Note comparison:

      
      model_name=File.basename(model_path,".skp")
      Sketchup.active_model.title == model_name
      # would return true
      
      
      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: New API doc - typos and questions

      @thomthom said:

      And the anchor link http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/point3d.html#%3C doesn't work for me under FF3.5. Might be due to the < character.

      I suggest the Google webmeister change the anchor to "#lessthan" instead of "#%3C".

      I would suspect that links to - and + methods may have problems with some browsers as well.

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

      @thomthom said:

      In FF3.5 I don't see this behaviour. What browser do you use?

      Currently still using MSIE 7

      P.S.: at MSDN it indicates if the cursor is not explicitly set, the browser decides; so it may indeed be a MSIE quirk. (I have MSIE 8 and FF on the computer in another room, I'll check and see how the site looks on that machine later today.)

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

      On the API docs pages, in the left nav column, whenever you have made a link bold, the cursor changes to a caret instead of the hand cursor. I suspect it's the <b> and </b> tags doing this.
      example from the API HTML source:

      <li><a href="/apis/..../model.html"><b>Model</b></a></li>
      

      Perhaps if the bold tags were outside the anchor tags?

      <li><b><a href="/apis/..../model.html">Model</a></b></li>
      

      If the css specifically set a tags such: a {cursor:hand} the nested bold tags should inherit their parent's cursor setting (according to the css reference.)

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

      @thomthom said:

      Tools observer that let you determine what custom Ruby tool is being used.

      YES I agree.
      Currently all custom Tools are reported as name="RubyTool" id="50003" state=nil
      (or similar.)
      In my custom Tool, I've made attribute getters tool_name, tool_id, tool_state but the ToolsObserver didn't ask for them I suppose. (or maybe it's the Tools collection?)

      Also the Tools collection does NOT work with custom RubyTools. Which may be the ToolObservers' problem as it gets it's info from the Tools collection.


      %(#804000)[(Addition:) I'd like some VCB methods (or extra parameters passed by current methods,) to supply VCB Label and VCB value.
      If new methods, something like:
      onVCBlabelchange( *tools, tooldata, vcblabel* )
      onVCBvalueentry( *tools, tooldata, vcbvalue* )
      tooldata = Array[ tool_name, tool_id, tool_state ]

      reason for labelchange event, is that we cannot rely on tool states as they vary too much, and worse, not all standard tools even use / change a tool state. So in order to know where a tool is in it's process we might be able to use what's displayed for the VCB prompt label.

      It would also be nice to get the VCB value after user entry from outside of a standard tool. (I know we CAN do it within our own custom tools using the onUserText method.) Uses, well I can think of implementing a entry history for standard tools, for one.]

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

      suggested Purgeevent methods,
      fire ONCE regardless of entities removed:
      (allows bulk handling in one event, instead of dealing with multiple events firing for each purged object.)

      onBeforePurge(*collection, itemsObjectArray*)
      onAfterPurge(*collection, itemsStringArray, purgeResult*)

      (onAfterPurge must return a an array of string names because the objects are now gone; the purgeResult would be the boolean returned from .purge_unused)

      for: DefinitionsObserver, LayersObserver, MaterialsObserver, StylesObserver
      (and any other new observer added that gets a .purge_unused method)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: How to show property value in HTML Description

      (edit) **Disregard - Off Topic**
      HTML

      
      <HTML>
      <HEAD>
      </HEAD>
      <BODY onload="GetXYfromRuby()">
      
      <INPUT TYPE=text VALUE="" NAME="LenX">
      <INPUT TYPE=text VALUE="" NAME="LenY" onchange="CalcArea()">
      
      <!-- put this description DIV anywhere you want -->
      <DIV ID="Description">This is the fabulous Rectangle component<p>You can set LenX and LenY<p>The calculated area, based on your input is <SPAN ID="Span_AreaXY"></SPAN></DIV>
      
      <!-- at the bottom of your webDialog HTML -->
      <SCRIPT Language="Javascript">
      function ShowAreaXY(AreaXY) {
        Span_AreaXY.innerText=AreaXY.toString();
      }
      function CalcArea() {
        var AreaXY;
        AreaXY=LenX.value*LenY.value;
        ShowAreaXY(AreaXY);
      }
      GetXYfromRuby() {
      window.location.href = 'skp;get_data@queryforXY';
      // your ruby callback will do two commands;
      // js_command = 'LenX.value=componentLenX;'
      // js_command = 'LenY.value=componentLenY;'
      // when LenY INPUT control gets value the onchange event fires
      //  calling CalcArea() which then calls ShowAreaXY
      }
      </SCRIPT>
      </BODY>
      </HTML>
      
      

      Havenot tested this, so you'll need to wring out the bugs.
      For example of the ruby callback, See:
      http://sketchupapi.blogspot.com/2008/02/sharing-data-between-sketchup-ruby-and.html

      posted in Dynamic Components
      Dan RathbunD
      Dan Rathbun
    • RE: How to show property value in HTML Description

      @nick60 said:

      So ... Dan ... proposed solution ... not viable.

      Woops.. sorry, I saw HTML and thot you were asking about webdialogs. (I guess it is the DC Properties Dialog you meant.)
      ... my bad! 😳

      posted in Dynamic Components
      Dan RathbunD
      Dan Rathbun
    • RE: Observers WhishList

      @unknownuser said:

      1. a new observer event onSaveBefore, which is fires before the model is saved by the user.

      The tradition in naming events [using DHTML events as a reference,] seems to be:

      1. Event names begin with "on".1. If a modifier is NOT needed, the event is usually always an after event, such as onclick. The event cannot fire until after the click occurs. (There are exceptions, such as onunload, which is a before event. Some browsers such as MSIE implement a non-standard alias called onbeforeunload. Anyhow.. unmodified names are or should be unambigious as to when they fire; ie: onunload would not be any use if it fired after the unload happens.) 1. If a modifier IS needed, there are two kinds:
      • Verb based: the eventnames end with a verb, with the modifier placed between "on" and the verb.:

      • onbeforeEventverb** onafterEventverb** Noun based: the noun follows the "on", with a modifier at the end.

      • onEventnounstart* onEventnounstop

      So, referencing the URL below and the way most SU API events are named, the eventname Fredo wants should be called ModelObserver.onBeforeSaveModel.
      The SU API for most Observer events follows close to the way that DHTML events are named. (There are events in both APIs that did not follow the naming 'convention', for whatever reason...?)

      ref: DHTML events
      http://msdn.microsoft.com/en-us/library/ms533051(VS.85).aspx

      I don't know why the W3C named events this way, but they did. (IMHO, I think even some of the Noun-based event names would be more clear with a 'before' or 'after' between the 'on' and noun.)

      The list at MSDN may give some readers ideas as to similar events or observers they would like in the SU API.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Use Sketchup default cursors

      @thomthom said:

      Do SU use .cur files? Isn't it just .png?

      Yes your right Thom, I boo-boo'd. Posted before I tested.

      SU does NOT recognize ****.cur**** files. If you try it the id for the cursor = 0. (I'm once again flabbergasted at whomever wrote the SU ruby API. They've earned 20 lashes with a Nerf-Noodle!)

      The API states 'image' but does not say what formats are acceptable.

      I've already begun extracting the 4 images files from the cursor files, decided to do a bit of anti-aliasing work on the edges of the pencils.

      DONE (Original posting now has updated zip with png images for SU cursors and buttons.)Get them...

      Will also look at the Windows API and see if I can cobble up a system call to load a cursor file instead of making a call to UI.create_cursor, as UI.set_cursor should not care how the cursor got loaded into memory, it only wants a pointer (id). [Some testing has shown the UI.set_cursor canNOT deal with Windows Cursor resources, so a 'special' set_win_cursor method would be needed, using a direct Win32 API call.]

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Use Sketchup default cursors

      %(#408000)[Yellow Pencil Cursors UPDATED!
      Now also in png image format; w/ new anti-aliasing edge work, small and large button images.
      See original post link below:
      ]

      http://forums.sketchucation.com/viewtopic.php?f=180&t=22204&p=198338#p198338

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Use Sketchup default cursors

      UPDATED!

      Here are 4 Yellow pencil cursors I made myself with Visual Studio (and converted to png with Paint.NET)
      They point NorthEast, NorthWest, SouthEast & SouthWest.

      Given in Windows .curformat, so you may use with any Windows Application; .. OR..

      and in .pngimage format for use with Sketchup custom tool(s) / plugins.

      • 32x32 png cursor images have hotpoint as part of filename
      • button images have size (16 or 24) as part of filename

      I grant permission to use freely for NON-COMMERCIAL purposes. I however reserve and retain Copyright under US code, and International Treaty (Berne Convention.)

      [read Copyright.txt for tips on use with Ruby, where to install etc.]

      UPDATED! Originally only in .cur format; Now given in png format with small and large button images as well. Cleaned up the bmp after conversion to png, and did anti-aliasing work on edges. ENJOY!


      Four Directional yellow pencil Cursors.
      Free for NON-COMMERCIAL use.
      Author retains Copyright.
      [read Copyright.txt for tips on use with Ruby.]

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Code] UnicodeEx - (0.2.0a) Sketchup + Character Encoding

      @thomthom said:

      ... Which means you need to give a Unicode string - which the ruby IO methods doesn't handle.
      What you need is to call the Unicode APIs that creates a file.

      OK I agree with that.

      It's the Fileand Dirclasses that STILLseem to have problems on Windows, even for Ruby ver 1.9.1
      see this bug report
      (I'd think the easiest solution would be to add a new parameter to many of the File and Dir class methods, ie "ANSI|UNICODE" for the mswin32 edition, that would give ruby coders a 'high-level' ruby way of forcing which API call to use, [ie: Ansi or Wide] without having to resort to direct API calls.)

      By the way several people have created unicode libraries (extensions) for string and character.. also iconvis mentioned.
      An old (2005) unicode library, this may be obsolete
      A list of extensions or gems at rubyforge for unicode and unidecode

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Code] UnicodeEx - (0.2.0a) Sketchup + Character Encoding

      @thomthom said:

      hmm... when does Ruby 1.8 ever treat strings as multibyte? From all my testing I found it to always treat strings as sets of single bytes. Though, please enlighten me if I'm incorrect -

      Looks like your right, in that respect (referencing your testing.)

      Maybe there's a hidden single/multi-byte flag or switch [for strings] setting we don't know about...

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Code] UnicodeEx - (0.2.0a) Sketchup + Character Encoding

      @thomthom said:

      Example, for the Kernel32function FindFirstFile I must call FindFirstFileW directly, because trying to call FindFirstFile will use FindFirstFileA. At least in SU7.0. I have not tried this after 7.1.

      This is not something that is caused by SU or Ruby... this is a Windows 'thang'. (Unless Ruby is somehow screwin' it up...)

      Sounds like you have an ANSI Windows version. Windows is 'supposed' to map the FindFirstFile call to either the ANSI version of the function ( FindFirstFileA) or to the Wide version ( FindFirstFileW) based on if the UNICODE flag is set at compile time.

      The MSDN website mentions 'extra' files are needed for Unicode support on Windows.

      I thought (maybe I'm wrong,) that most foreign sold Windows versions were specially compiled as Unicode versions.

      But like I said, I was having similar problems, seemed like it was the Wide versions that were being called for me, instead of the ANSI versions. This is strange...

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Code] UnicodeEx - (0.2.0a) Sketchup + Character Encoding

      @thomthom said:

      Isn't $KCODE related to Ruby 1.9?
      No, it cannot be, because the book was written for Ruby ver 1.6.x

      @thomthom said:

      (And are you sure it's set by SU - and not some ruby plugin?)

      I turned all my plugins OFF, while doing development. And it must be SU that sets it.
      I was having problems making Win32API calls, seemed the ANSI version was not being used, so I called it specifically, but didn't work at first. Then it did.. still don't know why. Anyhow I thought the default $KCODE setting was causing Windows to use the Unicode versions by default.
      I tried changing it to ASCII and it didn't seem to make any difference as far as the Win32API call. Every time it failed, and I made a change, I totally rebooted SU. And then it suddenly worked, not because of anything I did. Anyhow.. weird glich maybe.. memory gremlins!

      What do you suggest? always use the Unicode Win32API calls?

      @thomthom said:

      AFIK the only Unicode support that 1.8 has is in the RegEx functions. Or have I missed something?
      Well... the book says "$-K Sets the multibyte coding system for stringsand regular expressions."

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