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: Writing Readable Ruby

      I like the for in loop because it works in Ruby, Python and JavaScript, among many others. (Wikipedia lists 22 languages with this type of loop.)

      And it does just what it looks like it does.

      Ruby:

      
      for item in collection
          process item
      end
      
      

      Python:

      
      for item in collection
          process item
      
      

      JavaScript:

      
      for (index in collection) {
          process collection[index]
      }
      
      
      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Writing Readable Ruby

      @cjthompson said:

      BTW, my version would be:

      
      > def concat(*args)
      >     return args.join('')
      > end
      > 
      

      Didn't know that would handle the to_s() issue. Thanks.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: VisMap v3 Beta Testers Needed

      Mac testers still needed.

      posted in Plugins
      M
      MartinRinehart
    • RE: [Plugin] Camera Stats

      @cmeed said:

      Can you tell me about imputing the aspect ratio? i use sketchup to design tv sets so 16:9. Also does the statistics window always disappear behind the main skp window? so we have to re-size our windows when its opened?

      Is it possible with this plugin to show a true camera zoom from a certain location? so i place my camera i can show what it looks like from this position and and THEN from that position what a zoom looks like?

      Sorry to be so long. Somehow I missed your post.

      On my PC, my stats window pops up in front of SketchUp. Stays in front until I click the SketchUp window.

      For zoom, use two scenes. Use the Cam Stats plugin to set both scenes' cameras to identical eye, target and up values, but different field of view values. The SketchUp animation should give you a proper zoom.

      posted in Plugins
      M
      MartinRinehart
    • RE: Writing Readable Ruby

      From a book I'm reading:

      
      UI;;toolbar_names.each do |name|
         puts name if UI;;toolbar_visible? name
      end
      
      

      De-Rubied:

      
      for name in UI;;toolbar_names() 
          puts name if UI;;toolbar_visible?( name ) 
      end
      
      
      posted in Developers' Forum
      M
      MartinRinehart
    • Writing Readable Ruby

      The more Ruby I write, the more readable my Ruby becomes. Odd, but the secret seems to be to do nothing the way the Rubyists In Crowd does things. Here's a useful function:

      
      def concat( *args )
          ret = ''
          for a in args do ret += ( a.to_s() ) end
          return ret
      end
      
      

      Four-space indentation is more readable. The for ... in ... loop is more readable than the each iterator. Putting parentheses after function and method calls improves readability. Always using a return statement to return values is another. Rejecting the whole Tim-Toady-loving basket of string notations in favor of just concatenating with the "+" operator is more readable.

      The Rubyists In Crowd will never think my code is cool. But Monty, my pet python who's looking over my shoulder as I write this, just said, "Martin, that's almost Pythonic."

      "Monty, please turn away for a moment. You'll puke over all my papers if you see what I'm about to write."

      Here's the official, Rubyists-approved-but-don't-show-Monty version of that function:

      
      def concat(*args)
        ret = ''
        args.each {|a| ret += a.to_s}
        ret
      end
      
      

      I'm a big believer in conventions, but I've never seen a language where the conventions always favor the less-readable form. Never.

      Or maybe I'm unaware of the deeper secrets of Ruby. Certainly the Rubyists In Crowd knows a lot more about Ruby than I do.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Run Validity Check

      I started with SU 7 and the Fix Problems button has never found a problem to fix.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: How do you make Ruby Scripts Pause

      @cjthompson said:

      Has anyone figured out how to use threads fluidly, so that ruby and regular sketchup will work at the same time?

      I tried. Miserable failures all.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: How do you make Ruby Scripts Pause

      @jim said:

      Hi Mark, welcome to the forum.

      I would recommend instead of simulating an animation, you make it an actual Animation.

      Amen.

      @jim said:

      This example uses the SketchUp timer to create an animation - also a good technique:

      http://sketchupapi.blogspot.com/2008/10/animate-yo-cheese.html

      I'd not be going there. If memory serves, the timer really wants an integer, so any time less than a second is no time at all.

      @jim said:

      Although I think you'll find using sleep won't work as you expect as it pauses all of SketchUp, not just the Ruby part.

      Right. I made several attempts to go down that road. Some were failures. The others were miserable failures.

      The right way to do it is to create a class that implements the Animation interface.

      I recommend Chapter 16 of my tutorial. It explains how to use the Animation interface and provides classes that you can call to move, scale and rotate things without ever needing the transformation matrix.

      When you look at the sample code in the Animation interface doc, you'll see it calls view.show_frame. You want yours to call view.show_frame( delay_time ). A time of 1.0/30.0 would run at 30 frames per second if your nextFrame() method took no time at all. That would be a good place to start if you really want about 24 fps.

      Scarpino has a chapter on animation in Automatic SketchUp, also. That's the way to go if you want to do an animated human.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Gtk GUI for scripting?

      I've used Tkinter with Python. It gives excellent results in about half the code wx requires. It's set of widgets isn't as extensive as wx, but it's much better than JavaScript's tiny set.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: What Every Programmer Should Know About Floating-Points

      @jim said:

      It would have been better to choose a shorter length than an inch for the default unit in SketchUp. It should probably be a millimeter at the largest.

      I've read that international domestic architecture is done entirely in millimeters. No fractions required.

      posted in Developers' Forum
      M
      MartinRinehart
    • VisMap v3 Beta Testers Needed

      The basic visibility map will be familiar to VisMap v2 users:

      vm1.jpg

      The VisMap v3 scene list is quite different:

      vm2.jpg

      First half dozen PC volunteers and first half dozen Mac volunteers become beta testers. You get a free copy of the 1.0 release. Email (MartinRinehart at gmail dot com) or PM to volunteer.

      posted in Plugins
      M
      MartinRinehart
    • VisMap v3 Coming Soon

      I've completed the code for VisMap v3. It adds the ability to set scene transition and delay times for the model and for individual scenes.

      It will also add another feature: a price, maybe ten bucks. I've not decided whether to leave or kill the free VisMap v2. You might want to grab it now: http://www.MartinRinehart.com/models/rubies/vismapdoc.html

      posted in Plugins
      M
      MartinRinehart
    • RE: [Plugin] Camera Stats

      Edit: 58 downloads and zero bugs? Hard to believe.

      Mac folks: any problems?

      posted in Plugins
      M
      MartinRinehart
    • RE: JavaScript to Empty Something

      They are the same:

      
      <html><body>
      
      <h1> Headline </h1>
      
      <button onclick='dump1()'> Dump1 </button>
      <button onclick='dump2()'> Dump2 </button>
      
      <script>
      
      function dump1() {
          alert( document.body.hasChildNodes() );
          document.body.innerHTML = '';
          alert( document.body.hasChildNodes() );
      }
      
      function dump2() {
          alert( document.body.innerHTML );
          while ( document.body.hasChildNodes() ) {
              document.body.removeChild( document.body.firstChild );
          }
          alert( '[' + document.body.innerHTML + ']' );
      }
      
      </script>
      
      </body></html>
      
      
      posted in Developers' Forum
      M
      MartinRinehart
    • JavaScript to Empty Something

      In my tutorial I've this little loop:

      
       while ( div.hasChildNodes() ) { // empty the div
              div.removeChild( div.firstChild );
      
      

      This works, but is it just the hard way to do this:

      
      div.innerHTML = ''
      
      

      ?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Quickly finding groups/comps in an Entity Collection?

      Is it guaranteed that groups/instances are a tree structure?

      One cycle (A is a member of B; B is, directly or indirectly, a member of A) turns a recursive function into an infinite loop.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Default animation settings, a 2nd question

      Microsoft (MSFT) deliberately made Windows programming as complex as possible, as was suspected by all who tried it (I'm one) and was later confirmed by internal documents ferreted out during the antitrust trial. It would be extraordinarily unlike Google to do any such thing. So you ask, "Why?"

      I can think of many simpler ways to do this. There are about 40 options. A single hash and documentation that enumerated and explained 40 keys would work. An array accessed by named constants options[TransitionTime] would work. Did I overlook some deep thinking that underlies the chosen design?

      Regardless, Appendix O of my tutorial now credits and thanks ThomThom, lists the names of the OptionsProvider objects and lists each provider's hash keys. It also has a few words on how to use the OptionManager and OptionProvider classes.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Default animation settings, a 2nd question

      Any idea why it was done this way? It looks like MSFT deliberately trying to make Windows programming as complicated as possible.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Default animation settings, a 2nd question

      Many thanks, APIMeister.

      posted in Developers' Forum
      M
      MartinRinehart
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 38
    • 39
    • 6 / 39