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
    • Simple, Clean Algorithm Wanted

      So far, I've created plenty of dirty, messy algorithms and I have no confidence that any of them is robust.

      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. (move = translate, rotate or scale; more for the camera).

      Here's where I am: there exists a single Conductor. Things that implement an act() method are Actionables. Each Actionable instance registers a desired start and stop time with the Conductor. During the specified time, the Conductor calls each Actionable instance every frame of the movie.

      Lets say that these are the Actionables and their desired start and stop seconds:

      actionables.jpg

      These are the seconds during which the conductor will be calling their act() methods:

      seconds array.jpg

      As we want the conductor to absorb as few clocks as possible, I've created a Call class. Each Call has a stop time and a list of Actionables to call. This is the list of Call objects:

      calls list.jpg

      The simple, clean algorithm for going from picture 1 to picture 3 is evading me.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Read Serial port or USB interface

      Highly likely that you can kludge something together and highly unlikely that the result will survive the next release of Windows or SketchUp. Can you solve the problem with a WebDialog? (The user clicks a "motor on" checkbox and you send "motor on" to sketchyphysics.)

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Multi-threading inside SketchUp

      @dan rathbun said:

      ... Suggest ...

      Dan,

      I've played a lot with threads in SketchUp Ruby and have zero useful results. Could you post a small example that actually works?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Attribute dictionary pairs into variables & values?

      @chris fullmer said:

      I've used both [hashes and dictionaries] before, just never really enough to feel like I know what I'm doing.

      Crash course in hashes (a very useful tool to have at hand):

      A hash is a dictionary and vice-versa. They are sets of key/value pairs. An array is one form of hash: arr[0] = 'fred'. The key is zero and the value is 'fred'. Arrays are commonly restricted to integer keys. The term "dictionary" is commonly used when the keys are single words. dict['name']='fred'.

      Ruby makes hashes dead simple (though only a devout Rubyist could love the syntax):

      Ruby-example.jpg

      In JavaScript, both objects and arrays are hashes:

      javascript-examples.jpg

      The last example shows that the key need not be a string. (True in Ruby if you start with a hash: h=Hash.new() or h={}.) The key can be virtually anything. I'm using SketchUp ComponentInstance objects as keys in the stuff I'm doing today (trying to get a lot of things moving all at once).

      In Ruby, an array must be indexed by number. A hash may be indexed by anything. In JavaScript, an array is really a hash, which wins the flexibility prize but you wouldn't enter them in a race.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Properties to save between scenes

      @pout said:

      Ok, but that's duplicating the entities, which i really want to avoid at all costs

      Add my vote. Would really be nice to have a blue ball and a red ball without having two otherwise identical balls.

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

      Bug: NameError:

      If you Save or Load, then Cancel, you get a NameError and the Save/Load terminates. That's exactly what you wanted when you clicked Cancel, so this one's harmless. Will be fixed next time I UL the file. For now, ignore it.

      posted in Plugins
      M
      MartinRinehart
    • RE: Threads Needed, Waits Wanted

      I had this brilliant idea (that was a total flop). Since the delay works between frames in an animation, why not just grab that one?

      Was working well until I moved the puts Time.now() - start out of the animation code and into the mainline:

      for i in 1..10 do waiter(500); puts Time.now() - start end
      

      That said something like 0.03, 0.06, ... So I moved a call to a continue() method into the animation in response to stop(). BugSplat.

      I think I know how to at least solve the starter problem. The animated "move" commmand stacks move specs that are then run in an animation. Kludgy? Yup. PITA? Yup. But it should actually work.

      posted in Developers' Forum
      M
      MartinRinehart
    • View? Thanks, TT!

      πŸ‘ As luck would have it, I needed to refer to the View docs today. Thank you, ThomThom, for your notes! πŸ‘

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Generate smooth 2d circle for screen

      @thomthom said:

      I want to ensure the circle appears smooth.

      I drew a 6" (physical, measured on my screen) radius circle, 100 segments, and it appeared smooth, except at the sides and top/bottom. There you could see individual line segments stepping by single pixels, an unavoidable consequence of the hardware's limitations. More segments wouldn't change this.

      At 6" radius, segments begin to disappear around 50s, are entirely gone at 60s. At 1" radius, there are no segments at 30s. At 3.5" radius, 45s is nearly segment-free.

      I'd go with s = 6r + 24; s = segments, r = radius in screen inches.

      posted in Developers' Forum
      M
      MartinRinehart
    • [Plugin] Ruby Console Pro #2

      Edit: New file (Sun. AM, 5/23/10) includes experimental animated Move code.

      Edit: I've moved ou(), out() and outs() outside the protection of the module so, for example, outs() can be used anywhere you would have puts(), before.

      Before I begin with the plugin, let me ask that those who like this thank Jim Foltz. I learned how to do this by studying Jim's WebConsole.

      This is strictly for developers, hence the announcement here. The console (RCP) looks like this:

      input_console.jpg

      If you click "Init" you get this:

      default_init_code.jpg

      You can provide, via Setup, your own init code. Code in the console is executed when you click "Exec" or when you press Enter in the RCP. The output window, for the above code, reports:

      sample_output.jpg

      The "Save", "Load", "Clear" and "Exit" buttons do what their names promise. "Output" toggles visibility of the Output window. "Setup" launches this dialog:

      setup_dialog.jpg

      This lets you provide your own default save file, your own init code and "One-touch" commands for F1 through F12 (skipping, on PC, F6). These commands execute immediately when you press the key. Since you can load a program with these keys, there's no theoretical reason why you can't create a model of the Taj Mahal with a single keystroke.

      As always, the window with focus receives keystrokes. One-touch commands work when RCP has focus.

      We are not heading toward an IDE, here, however. Reason: HTML's textarea widget is not suitable for serious text editing. Sorry.

      Extract to your Plugins directory. Ruby Console Pro is added below the Ruby Console in the Windows menu. Use outs to output a string (plus a newline). Use out to output a string plus a single space. Use ou to output a string and nothing else.

      Edit: Version 0.? in continuous use developing move code.


      ruby_console_pro.zip

      posted in Plugins
      M
      MartinRinehart
    • RE: View.invalidate vs view.refresh

      @chris fullmer said:

      I am thinking that maybe if you are moving geometry by increments, it will not show that movement with invalidate.

      Airshow! is done with an invalidate() at the end of each frame's transformations.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Generate smooth 2d circle for screen

      Don't understand the question. Are you trying to compute a matter of taste?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: New SketchUp Version

      @tig said:

      This happened to most users a week or two ago - it told you even if you had the latest version [rubbish update checker by Google means you get nagged when you do have the latest version !?]... Your PC seems to be just slow in catching up πŸ˜‰

      "I forgot to wind the sundial. Now it's stuck on yesterday."

      R. Hunter

      posted in SketchUp Discussions
      M
      MartinRinehart
    • New SketchUp Version

      SketchUp is telling me there's a newer version.

      Any info on this?

      posted in SketchUp Discussions sketchup
      M
      MartinRinehart
    • RE: Move component to wall but after but disappears

      @jacm said:

      I now seem to be having trouble lately moving a component to something like a wall but as I move it, it is "flashing" on and off

      Sounds like you have a damaged model. Your file size looks way too big.

      Also, your little elbow thingies (that you can barely see) are slick but very high poly. 141KB, each. Delete one of them. Make the other one a component (right click, Make Component). Move/Copy will recreate the deleted one, and save 141KB. Copied components weigh only a few bytes. Copied groups weigh just as much as the original.

      posted in Newbie Forum
      M
      MartinRinehart
    • RE: Export google sketchup file to other software

      @henda said:

      Ruby script or Ruby extensions written in C\C++ can export google sketchup file to other software that accept only xml file?

      Do you need something general-purpose (very hard) or more specific (possibly easy)?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Web Dialog bug?

      @brett mcallister said:

      Thanks for the replies.
      The only ruby code I am using is just to load the dialog to test it so there is no namespacing etc.
      Sounds like that will solve the problem,so I will keep that in mind as I get further along.

      Cheers
      Brett

      Failure to include two parameters in the code block of an action callback is a crime punishable by BugSplat.

      PC or Mac?

      posted in Developers' Forum
      M
      MartinRinehart
    • Threads Needed, Waits Wanted

      I've added an extra parameter to my SketchTalk m command. It's the number of seconds over which the move should be done. This floats a component instance referred to by b up 20 units in 5 seconds:

      m b, [0,0,20], 5

      Problem is, this may or may not execute a single frame of the first move:

      m b, [0,0,20] m b, [20,0,0]

      This is the movie function:

      
      def movie( args ) # animated move
      
          inst = args[0]
          vec = args[1]
          nsecs = args[2]
          
          nframes = nsecs * $sketch_talk_fps # $sketch_talk_fps is a float
          frame_vec = [ vec[0]/nframes, vec[1]/nframes, vec[2]/nframes ]
          mover = Mover.new( frame_vec, nframes, inst )
          anim = Sketchup.active_model.active_view.animation = mover
          
          puts 'main? ' + (Thread.current == Thread.main).to_s()
          until anim.done
              puts 'done? ' + anim.done().to_s()
              Thread.current.sleep( 100 )
          end
          
      end # of movie()
      
      

      Yes, it reports, Thread.current == Thread.main

      No, it reports, anim.done is false.

      It reports this exactly once. I am trying, via the loop at the end of movie() to wait for the animation to finish before going on to the next one. But it seems that the wait loop doesn't do any waiting.

      The @done is set to false in the Mover constructor, reset to true in the Mover's stop() method. The View calls stop() correctly.

      The Ruby code has priority. An infinite loop (no call to sleep) loops infinitely and no animation takes place. Calls to Thread.yield() don't work, either.

      posted in Developers' Forum
      M
      MartinRinehart
    • How Many Are in This Army?

      When I first joined, a moderator sent a nice "Welcome" message and told me that I was # 20,001.

      How many are we now?

      posted in SketchUp Discussions sketchup
      M
      MartinRinehart
    • RE: [Plugin] Camera Stats

      @jim said:

      Need to open it modal on the Mac to make it stay on top.

      Thanks, Jim.

      I changed it to "show_modal" but it turned the friendly little guy into a huge pain. Almost useless. Certainly no fun.

      Mac users: edit the code. It's ...Plugins/camera_stats/camera_stats.rb. Change the line at the bottom that now reads "wd.show()" to "wd.show_modal()". Is that better?

      posted in Plugins
      M
      MartinRinehart
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 38
    • 39
    • 5 / 39