sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    AppleScript, Ruby, Threads and Unix... help!!!

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 266 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      driven
      last edited by

      A few of you know I've been messing with this mix for far too long now, and some may know I finely got some things working.
      I have a robust way of manipulating SU with AppleScript from SU ruby.
      I can seed the Applescript with returns from Ruby before running in 'osascript' and I have a roundabout, but fast way of getting returns from AppleScript back into ruby.

      But it's all a bunch of disjointed snippets that I want to pull together in public, where I can hopefully get some help and advice.
      Jeff's suggested a sort of 'milestone' idea in another thread that I may use as the first target, my own begin more 'grandiose'.

      With all my detours I haven't been paying enough attention to 'basic' ruby, although I have been using system ruby from SU to do some bits quite successfully.

      The main reason I've used it is I don't know how to get SU ruby to 'wait' without causing beach-balling.

      a simple example is when I write a file in one process and close it, unless I have a button or message box, SU ruby will error when I try to read that file, or it will read it before it's updated, I have tried moving, renaming, exist?, is_readable? and goodness knows what else, but without physical delay i can't figure it out...

      hope for assistance
      john

      learn from the mistakes of others, you may not live long enough to make them all yourself...

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        The only way that we can "wait" to do something in SketchUp without "beach-balling/whiteout" (because SU controls when Ruby runs,) is to use a timer loop:

        @tid = UI.start_timer(@delay, true) {
          if @file_is_ready_to_read
            @UI.stop_timer(@tid)
            read_my_file() # call a local method
          end
        }
        

        So the code that writes the file needs to set the @file_is_ready_to_read boolean to true.

        If this happens in another process, you would need something like TBD's sub.exe to trigger the variable change, or perhaps DRB (distributed Ruby.)

        ... Or some kind of net protocol like a UDP message from one process to another.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          Cheers Dan,
          I'm sure a timer before but will revisit... for the moment a couple of us have highjacked Jeffs thread, to work a few thing out... I'll post some bits back here when there usable...
          john

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement