sketchucation logo sketchucation
    • Login
    1. Home
    2. MartinRinehart
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 131
    • Posts 766
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Textarea line separators on Mac

      Anyone?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Open URL on local disk

      Anyone?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Python/Ruby vs. Ruby/Python

      @jessejames said:

      @martinrinehart said:

      when do we start building this thing?

      http://www.MartinRinehart.com/posters/decaf.html

      Got a lexer running, tho it's blocks are delimited, not indented. Begun a parser. I only pick on this a bit at a time. (In Python, of course.)

      The declaratives (func defs, classes, etc.) should be processed first so the user can decide that the mainline would best come first or last or where it makes sense. Language design shouldn't dictate source code structure. When I wrote Java, for example, I had one special place for main(). It was important that it always resided in its special place as it was typically test code, commented out when the class was finished. Once commented out, the IDE couldn't see it.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Open URL on local disk

      @tig said:

      you need to add the Plugins folder path to the start of the rest of the path it uses ?

      That file isn't in Plugins. It's in C:/r2/. Oddly, when I add "C:" to the location, UI.openURL() reports true, but an open file in my default browser doesn't happen.

      posted in Developers' Forum
      M
      MartinRinehart
    • Python/Ruby vs. Ruby/Python

      This is off topic. I'm posting this so that those who want to join the debate will have a place to do so. Hopefully, we'll not have the topic raised elsewhere.

      I have a pet Python named Monty. Monty promises to give Tim Toady a big hug if he ever meets him. (No, you do not want a big hug from Monty.) You can figure out where I stand.

      On the other hand, I know some experienced, productive code weavers who love Tim Toady. Fine. (But don't bring it up around Monty.)

      Python's suites (four-space indented code blocks) are great. They enforce good code writing. Ruby's if/unless pairing, and especially suffixing, are great. Python's lambda functions and Ruby's blocks are no match for the elegant simplicity of JavaScript's functional programming.

      Python lacks the implicit "this" of C++ and Java. It's a pain. Not being able to wrap your code in a module without changing all your def func() to def self.func() is a Ruby pain. And what was Matz thinking when he decided that the programmer, not the language, had to write explicit type coercions? ("foo"+23) == "foo23" in most of the languages I know.

      And I find the processing of code in the order it appears in the file is utterly lame. Even JavaScript has sense enough to eat all the declarative code before it starts running imperative code. Matz? Guido? This is 2010!

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Open URL on local disk

      @cjthompson said:

      ...do you have a code example?

      Hmmm. What's going on?

      
      # /r2/open_st_help.rb
      
      require 'sketchup'
      
      help = "/r2/sketch_talk.html"
      file = File.new( help, 'r' )
      arr = file.readlines()
      file.close()
      puts arr[0]
      
      puts UI.openURL( help )
      
      

      The file reads correctly. (Eliminate typos in address constant.) But doesn't open:

      lineYes_urlNo.jpg

      posted in Developers' Forum
      M
      MartinRinehart
    • Textarea line separators on Mac

      My PC <textarea> lines are separated by crlf: 13, 10. Does anyone know what that is on a Mac?

      In the following script, Ruby launches a WebDialog with a text area with two lines ("one" and "two"). The WebDialog calls Ruby after it is loaded. The Ruby callback grabs the text area's value, and writes it to the console, one number per character. The separator(s) will appear between 101 ("e") and 116 ("t").

      Thank you!

      
      # ta_sep.rb 
      
      require 'sketchup'
      
      html="
      <html> <body>
      
      <textarea id='ta'>one
      two</textarea>
      
      <script>
          onload = function() { location = 'skp;go'; }
      </script>
      
      </body> </html>"
      
      wd = UI;;WebDialog.new( "Test", true, "test", 400, 300, 100, 100, true )
      wd.set_html( html )
      
      wd.add_action_callback( "go" ) do | dlg, msg |
          val = wd.get_element_value( 'ta' )
          for i in 1..val.length do puts val[i-1] end
      end
      
      wd.show()
      
      

      wd.jpg

      rc.jpg

      posted in Developers' Forum
      M
      MartinRinehart
    • Open URL on local disk

      I've not found a way to use UI.openURL() to open a file on a local disk. Anyone done this?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: HELP setting up a SU code editor

      @driven said:

      I hadn't grasped that your, "hey guys, no need to look under the hood" API was devised to slow peoples own programing knowledge.

      I invite you to take a quick look at my table of contents. Chapter 15 covers programming with the Transformation class methods. Chapter 16 covers the "no transformation matrix" programming. 16 also includes a critique of the "no transformation matrix" programming, explaining where it is not enough.

      Appendix T covers the matrix in depth for those who want to get under the covers of the Transformation class. Appendix MM explains matrix multiplication.

      This is all "devised to slow peoples own programming knowledge"?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: {paint bucket - F/boards) in different directions

      @jacm said:

      I then want to lay them in the kitchen - west to east, but they all only go in 1 direction.

      Those SketchUp carpenters are much cleverer than you might think. This one has some other techniques for laying floorboards:

      http://www.MartinRinehart.com/models/tutorial/tutorial_m.html

      If you're a newbie, go straight to the hints.

      posted in Newbie Forum
      M
      MartinRinehart
    • RE: WebDialog.set_html() Gotchas

      "Any customer can have a car painted any color that he wants so long as it is black." H. Ford

      There is no doubt that JavaScript is the best language for code running in the browser. Ruby is absolutely the best choice for SketchUp plugins. For similar reasons we've chosen HTML and CSS.

      However, if you know a man whose pet Python is named Monty, you may infer something about his personal language choice. (Monty just reminded me that van Rossum works for Google. There's hope.)

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: WebDialog.set_html() Gotchas

      @unknownuser said:

      Works for me on a Mac - no errors shown.

      Does Safari read from a file, or is it given the HTML otherwise? On a PC, I'd throw an error into the code and MSIE would report the URL.

      @unknownuser said:

      You gotta double your backslashes if you want backslashes.

      Because char substitution goes on during the file writing: \\x0a is an escaped backslash followed by the literal "x0a", which is written as a single backslash followed by the literal "x0a" which is the hex literal \x0a.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: WebDialog.set_html() Gotchas

      @unknownuser said:

      Can you post a failing (small, complete) example?

      
      require 'sketchup'
      
      html="
      <html> <body> <script>
      crlf = '\x0d\x0a'
      </script> </body> </html>
      "
      wd = UI;;WebDialog.new( "test", true, "test", 500, 500, 0, 0, true )
      wd.set_html( html )
      wd.show()
      
      

      Code typed, not run, but should be close. On error, note the name of the file. Load it in your editor and note the difference between your html variable's content and the file's content.

      @dan rathbun said:

      .
      And a good example of why I like Ruby so much:

      Js:
      %(#8000BF)[crlf = String.fromCharCode( 13 ) + String.fromCharCode( 10 );]

      Ruby:
      crlf = 13.chr<<10.chr

      I couldn't tell if you were being serious or sarcastic. The Ruby's terse but it wins no prizes for readability. I'd replace either of these with crlf = ASC(13) + ASC(10).

      And watch what you say on this as Monty, my pet Python, also reads these posts. Trust me, you want to stay on his good side.

      Edit: Do I have that backwards? CHR(13) + CHR(10)?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: IE9 looking good

      @hfm said:

      Well yeah, I/we have been ranting about updating IE. But it feels more like the're changing it with every number.

      If you are a very big, very rich software company you can have team A working on version N, while team B works on version N+1. As a guess, the IE8 team is now on IE10.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: HELP setting up a SU code editor

      @chris fullmer said:

      I have to admit that I do not understand what an IDE does over just using Notepad++ ...

      In the [not so] good old days, we had an editor, compiler, linker, debugger, etc. For reference, we had treeware. An IDE gathers them all in one place.

      In the [not so] good old days, your cycle was edit, compile, link, run. With today's tools, compiling and linking happen in milliseconds (used to be minutes). An IDE has a single-key compile/link/run command. You probably click your console, up-arrow and Enter. Not quite as nice as one key, but really no big deal.

      What we lack is a proper debugger. Additional IDE tools include screen painters for menus, input forms and so on. Also, complete help systems. Modern IDEs do so much that they also feature serious learning curves, so they are not appropriate tools for those who don't earn their daily bread by coding.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: HELP setting up a SU code editor

      @dan rathbun said:

      I'm happy with Notepad++ as an editor,

      It's really strong with HTML and JavaScript, but pretty weak on Ruby. Minimal coloring, only a faint try at matching begin/end constructs, ...

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Set camera, and move shape by end point

      @lib said:

      Martin I will have a look at the API you offer , I think it is going to help me in my project.

      Do keep us posted!

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Compute Rotation and Scale from Transform Object

      @dburdick said:

      I read your wonderful web-page description of the 4 x 4 matrix - ...

      Very kind words, indeed. Many thanks.

      For those not versed in the Transformation Matrix, my tutorial's Appendix T, introduces it, Appendix MM explains matrix multiplication and Chapter 16 explains how you can live without it (and includes a Matrix class, just in case).

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Compute Rotation and Scale from Transform Object

      @dburdick said:

      Is there a simple Sketchup Ruby method which returns the x,y and z rotation in degrees ...

      What's the application for this? (Scaling modifies the xform's [0,0], [1,1], [2,2] entries. Rotations modify all entries from [0,0] through [2,2]. It's not immediately obvious that you can find original operations in any non-trivial case.)

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: HELP setting up a SU code editor

      I'm a veteran of both Eclipse and NetBeans and highly recommend both for large projects. Haven't seen the benefit of trying either for Ruby plugins.

      I don't know of any progress on the polylingual problem. In Java, you could use HTML in the JavaDoc, but the editor didn't really get the "language switch here" message. Maybe it's gotten better in the last couple years.

      This problem is taken to the extreme in WebDialog work. My current project has one file mixing Ruby, JavaScript, HTML and CSS. If you find a tool that will do syntax highlighting for something like this, do let us all know!

      posted in Developers' Forum
      M
      MartinRinehart
    • 1 / 1