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: I have been a Plugin Harlot

      @tig said:

      path = File.dirname(__FILE__) does what you think

      That's actually quite filled with issues. If your script said load '../relative/path/filename.rb' then File.dirname(__FILE__) is ../relative/path/. Better to use File.expand_path( File.dirname(__FILE__) ). That gets the full path and, on PC, drive letter.

      posted in Plugins
      M
      MartinRinehart
    • [Plugin Update] Ruby Console Pro with SketchTalk in Motion++

      Edit: 6/7/2010 New file. Minor bug fixes. Added file: heavily annotated demonstration script.

      Edit: Now (6/1/10, 9:15AM) includes very early version of this gizmo:

      video_player.jpg

      Edit: Even newer file! Get your movie director duds on and control the camera! See post #11 below for instructions.

      Edit: New file! Now moves, rotates and scales.

      Pioneering code. To pioneer you must be strong and fearless. Absolutely nothing is guaranteed. Edit: No reports yet of any fried computers.

      This plugin lets you add motion to your models without any of the complications you used to meet. You can move one or more component instances at once, each doing one or more separate motions at times you specify.

      In this sample script I open a background model, then import my biplane. It is imported to the origin. The first move (no start/stop times specified) slides it to the side instantly. The other moves specify start and stop seconds. It rolls forward and back, then takes off and flies away. Then I import "blueplane" and it does roughly the same. Note that "blueplane" does nothing between seconds 6 and 10. It waits for biplane to catch up.

      
      n
      open '/models/airshow/background.skp' 
      
      bp = i '/models/airshow/biplane'
      none
      
      m bp, [0,250,0]
      m bp, [100,0,0],0,5
      m bp, [-100,0,0],5,10
      m bp, [100,0,100],10,15
      m bp, [1000,0,0], 15,20
      
      bp2 = i '/models/airshow/blueplane'
      none
      
      m bp2, [-100,0,0], 0,3
      m bp2, [100,0,0],3,6
      m bp2, [100 ,0,100],10,15
      m bp2, [1000,0,0], 15, 20
      
      go
      
      

      These are the non-obvious bits:
      n - Ctrl+A, Del (File/New without the "Save changes..." dialog)
      none - clear all selections (use "none" often)
      go - begins executing the specified movements

      During motion you can orbit and zoom. (If you're quick you can open a component for editing while it moves. If you see smoke coming from your computer, maybe that's not a good idea.)

      The code above works on my computer because I've got, for example, a biplane in /models/airshow/biplane.skp. You can try the following starter script that creates its own components. Copy here, paste into your Ruby Console Pro and click "Exec". Who says there's no magic in the world?

      
      n
      box o, [20,20,0], 10
      box1 = g 'box1'
      m box1, [20,20,30], 2, 20
      m box1, [-20,-20,-30], 20, 30
      none
      
      box o, [-20,-20,0], 10
      box2 = g 'box2'
      m box2, [-20,-20,30], 4, 20
      m box2, [40,40,-20], 25, 30
      none
      
      box o, [-20,20,0], 10
      box3 = g 'box3'
      m box3, [-20,20,30], 8, 20
      m box3, [40,-20,-10], 23, 27
      none
      
      box o, [20,-20,0], 10
      box4 = g 'box4'
      m box4, [20,-20,30], 12, 20
      m box4, [-20,40,0], 20, 23
      
      all
      
      go
      
      

      Edit: There are additional scripts in later posts. They keep getting better!

      Extract the file into your Plugins folder. It adds a "Ruby Console Pro" item under "Ruby Console" in your "Window" menu. Launch and click "Setup" and set the default file to some folder that makes sense on your machine. Now you're ready to get moving.

      Edit: Mac? You're almost ready. In the Plugins/ruby_console_pro folder there are three HTML files. In each you have to slip in a "1" in front of "0px" so it becomes "padding: 10px;". There's a comment at the appropriate spot.

      If you animate instances that are part of other instances, do let us know what happens. Bug Splat if you're lucky? Smoke if you're not?

      F1 is set for SketchTalk help. You'll see that scale and rotate have little demo animations, but aren't yet integrated. I've got more to do. Edit: With any luck, scale and rotate happen this weekend! Edit 2: Two boxes rotating, 8:35 AM, Saturday! Edit 3: Box correctly scaled! Moved, rotated and scaled simultaneously, 11:05 AM. Edit 4: New demo script features four boxes moving, rotating and scaling and it's way more fun than just moving! On to package all this up and UL the file. 11:22 AM.

      I've still got work to do. You need something similar for the camera. Edit: The camera eye moved over 3 seconds, 8:12 AM, Sunday morning. Moved by a vector, 8:34. Camera's field of view (zoom) is animatable, 10:12. Camera's target animatable, 10:59! Now to create a little doc and UL a new file. First, though a nifty demo script.


      Heavily annotated script. DL to any convenient folder.


      Extract to Plugins. Bug fixes through 6/14.

      posted in Plugins
      M
      MartinRinehart
    • RE: Create an entirely custom toolbar that loads ruby plugins?

      My tutorial, starting in Chapter 11 teaches the basics of Ruby programming with the SketchUp Ruby API. I don't cover toolbars, however.

      Scarpino's book Automatic SketchUp covers toolbars briefly.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Instance Transformation Reference Issue

      Problem is it moves with a new Transformation. I think I've got Transformation.set! mastered so I don't have to change TMs. Will know soon.

      posted in Developers' Forum
      M
      MartinRinehart
    • Instance Transformation Reference Issue

      I give these two commands, expecting to move a component over the first five seconds and then move it back over the next 5 seconds.

      
      m comp, [20,20,30], 0, 5
      m comp, [-20,-20,-30], 5, 10
      
      

      The result, however, is that the second move command starts by placing the component back in its original position before beginning its move.

      Internally, these commands are placed on a stack. The first moves nicely, but it does this by replacing the instance's transformation reference. The second move references the same component, but it was nicely copied so it could keep its original transformation reference.

      I didn't copy it. Ruby did. I've been trying to get around this using Transformation.set!(), but so far without success. Any ideas for a clean solution? Or do I have to look through the stack, replacing, for each component, transformations with the latest?

      Making transformations easy is proving difficult.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Very Odd Bug

      @tig said:

      Glad we helped 😉

      Are your martinis as dry as your humor?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Making Movies from Models

      Thanks to both!

      @chris fullmer said:

      Like how would you export your airshow animation as a video format you could upload to youtube?

      That's it, exactly. Yes, my controller steps through one frame at a time. Is there an API method for exporting screenshots?

      posted in Developers' Forum
      M
      MartinRinehart
    • Making Movies from Models

      How does an animated SketchUp model turn into a YouTube-capable movie?

      posted in Developers' Forum
      M
      MartinRinehart
    • Very Odd Bug

      Edit: Problem solved. Thank you for stopping by to lend a hand.

      Stupid Programmer Trick # 38,298,987,234

      The first component to start moving was shorted by one second. Had nothing to do with the quadrant.

      In this script:

      
      load( Sketchup.find_support_file('sketch_talk.rb', 'Plugins/ruby_console_pro/') )
      n
      box o, [20,20,0], 10
      box1 = g 'box1'
      m box1, [20,20,30], 0, 20
      none
      
      box o, [-20,-20,0], 10
      box2 = g 'box2'
      m box2, [-20,-20,30], 4, 20
      none
      
      box o, [-20,20,0], 10
      box3 = g 'box3'
      m box3, [-20,20,30], 8, 20
      none
      
      box o, [20,-20,0], 10
      box4 = g 'box4'
      m box4, [20,-20,30], 12, 20
      none
      
      go
      
      

      four boxes are created in the four rg quadrants. Translating SketchTalk to English, that's:

      
      n # select all, delete (quickie File/New)
      box o, [20,20,0], 10 # Rectangle, origin to [20,20,0], PushPull up 10
      box1 = g 'box1' # Create ComponentInstance named 'box1'
      m box1, [20,20,30], 0, 20 # schedule a future move during seconds 1 through 19
      none # unselect everything
      
      ...
      go # begin the scheduled moves
      
      

      Each box schedules a move, 20 units out into its quadrant and 30 units up the blue axis. They move, which is great.

      But the box in the positive r, positive g quadrant doesn't quite do a full move. The move code is quite simple-minded. It divides the move vector into distance per frame. It has nothing to do with quadrants.

      
          def create_amcis() # convert registrants into actionable, movable CIs
              for reg in @@registrants
                  duration = reg.stop - reg.start
                  frames = duration * $sketch_talk_fps
                  r = reg.vector[0].to_f() / frames
                  g = reg.vector[1].to_f() / frames
                  b = reg.vector[2].to_f() / frames
                  reg.actionable = Con_Amci.new( reg, r, g, b )
              end # registrant loop
          end # of create_amcis()
      
      

      The move vector is [20,20,30]. Actual move is speed-dependent:
      5 sec. [16,16,24]
      10 sec. [18,18,27]
      20 sec. [19,19,28.5]
      40 sec. [19.5,19.5,29.25]

      The other three boxes animate happily to a full [20,20,30]. Shuffling the box order doesn't change the behavior. The box in the positive red, positive green quadrant doesn't do a full move.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: An entertainment cabinet

      @smoscowitz said:

      I want to build an entertainment center.
      I would like to try and design it on sketchup.
      The program opens with a perspective view.
      Is that all there is?

      Basics: SketchUp lets you build 3D models. The model's the thing. Usually you'll want to view it in perspective. Top, front, back, side and bottom views are also available. Xray views, too. Lots of choices, but the model's the thing.

      Start with a Rectangle. PushPull it into 3D. Then learn to Orbit, Hand (not its real name, but H is the keyboard shortcut and it looks like a Hand on the toolbar and when you use it) and Zoom in and out.

      I wrote a tutorial on this. It's still free.

      posted in Newbie Forum
      M
      MartinRinehart
    • RE: Terrible time with sketchup

      @gadgetmanmike said:

      I use the tape measure and often it just plain doesn't create guide lines even tho. it just did and the tool is still selected.

      If you measure from an edge (line) out along a face you get a guide.

      If you measure from a vertex (line intersection) SketchUp thinks you are measuring and reports the distance.

      AutoCAD is a drafting tool. SketchUp is a designing tool. Don't get sucked into silly discussions of which is better. Both are excellent at their core purpose.

      Try my tutorial. It's still free.

      posted in Newbie Forum
      M
      MartinRinehart
    • RE: [Plugin] Ruby Console Pro #2

      Updated 5/21. New file in original post.

      posted in Plugins
      M
      MartinRinehart
    • RE: Simple, Clean Algorithm Wanted

      @dan rathbun said:

      @martinrinehart said:

      I am working on a multi-move animation controller. By multi-move I mean one which allows multiple things to move at different times, times probably overlapping so multiple things can move at once.

      Have you investigated the standard Ruby library class Mutex ?

      http://phrogz.net/ProgrammingRuby/tut_threads.html
      ... and scroll down about 3/4 of the page.

      As always, Dan, I learn from your posts.

      I tried to work my way through this chapter, but had very little luck replicating the book's results. Gave up before Mutex.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Question about the vector direction

      This bit of code is unusual:

      
      vector = ...
      vector2 = vector.normalize!
      
      

      By convention, Ruby methods that end with a "!" work directly on the calling object's data. So vector.normalize! normalizes vector. You now have the normalized data in vector and a second reference to it in vector2. Not sure that was what you intended.

      I added a comment to the Vector3d class doc to clarify this. (If you learned from the doc you were misled.)

      posted in Developers' Forum
      M
      MartinRinehart
    • SketchUp Crashing w/o Bug Splat

      I had a problem with frequent silent crashes. SketchUp, its dialogs and mine just disappeared.

      Problem fixed when I saw a foo that should have been an @@foo.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Simple, Clean Algorithm Wanted

      Algorithms based on looping over the registered actionables were impossible. Looping over the seconds made it a piece of cake.

      
          def organize() # converts list of Registrants to list of Calls
              call_ptr = 0
              @@call_list.push( Calls.new(1, []) )
              last_sec = find_last() - 1
              old_list = []
              
              for sec in 0..last_sec
                  list = []
                  for reg in @@registrants
                      list.push( reg ) if reg.wants_call?( sec ) 
                  end
                  
                  next_sec = sec+1
                  if list == old_list
                      @@call_list[ call_ptr ].stop_time = next_sec
                  else
                      @@call_list.push( Calls.new(next_sec, list) )
                      call_ptr += 1
                      old_list = list
                  end
              end # seconds loop
              
          end # of organize()
      
      
      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Ruby Docs

      @dan rathbun said:

      Found a better version of the 'Pick-Axe'

      Great stuff!

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Reading a file in Ruby

      @wsellers89 said:

      I am experienced in Fortran and to a less extent C, but I can follow most of the the code.

      In most modern languages there is a loop that loops over each member of a group without need for subscripting (and therefor without chance to mess up by going one too far or one too few). In Ruby it's

      for member in group do process_member_here end

      For non-trivial processing its

      
      for member in group
          process_member_here
      end
      
      

      Your job might go like this:

      
      first = true
      for point in points
          create_edge( prev, point ) unless first
          prev = point
          first = false
      end
      
      

      You'll see many Rubyists write that this way:

      
      ...
      points.each do |point|
      ...
      end
      
      

      My tutorial, beginning in Chapter 11 teaches Ruby and the SketchUp API. It has "Topic" boxes for programming beginners. Programmers such as yourself who know coding essentials, but not Ruby, can just read the topic (for example, "Looping") and, if you know what the topic means, you skip over the box.

      By the by, Chris's You Tube tutorials are a lot more fun.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Simple, Clean Algorithm Wanted

      Thanks, guys. I've figured it out.

      In each actionable:
      def wants_call?( sec )
      ----return sec ( >= start ) && ( sec < stop )
      end

      In Conductors get_organized()

      call_list = []
      previous_list = []
      call = Call.new( stop_sec = 1, list = [] )

      1. find the last stop time.
      2. Loop over each second (0..last-1).

      Each second asks everyone "do you want a call this second?"

      Those who say "yes" get pushed onto a list.
      Is this list == previous list?
      ----Increment current Call's stop time.
      Not equal?
      ----Append current call to call_list.
      ----call = Call.new( stop_time is this second plus one, list is the current list ).
      ----previous_list = this list

      Done? Push last Call onto call_list.

      Fast? No. Robust? Yes.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Simple, Clean Algorithm Wanted

      @chris fullmer said:

      I can't follow the progression from 2 to three I guess.

      That makes two of us! I'll re-explain 3.

      In second 0 there's no one to call.

      In second 1 R2 gets called.

      In second 2 R0 and R2 get calls.

      In seconds 3 through 6, everybody gets calls.

      etc.

      @cjthompson said:

      if possible, could you do a fairly simple psuedo-code of your current algorithm?

      Conductor's job is in three phases
      1) While folks are registering, just add them to the list
      2) When given a start signal, get organized, then insert self as view.animation
      3) When running, do minimum work to call those who need calls

      Conductor's nextFrame() method (phase 3) looks like this:
      each frame, increment frame
      if frame is multiple of frames_per_second
      increment second
      if we've reached the stop second, grab the next Call
      once every few seconds, check speed, adjust delay as needed
      call everyone in the current Call's list
      call view.show_frame( delay )

      I think the call_list structure is close to minimizing the time spent in the conductor after the animation starts.

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