sketchucation logo sketchucation
    • Login
    1. Home
    2. RichMorin
    3. Posts
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 41
    • Posts 104
    • Groups 1

    Posts

    Recent Best Controversial
    • Need help on writing threaded plugin code

      I've looked around for information on writing threaded plugin code,
      but I'm not having much luck. (Of course, part of the problem has to do with the overloading of the words "thread" and threaded". <g>) Does anyone here know the ropes?

      I have a plugin that needs to scan a directory for the presence of new files, processing and removing them when they appear. Something like this:

      
      loop do             # Loop forever, handling files.
        paths = Dir.glob(patt)
      
        if paths.empty?   # Nothing to do; zzz...
          sleep(0.05)
        else              # Process incoming messages.
          paths.each do |path|
            process_input(path)
            break if @terminate_bd
          end
        end
        break if @terminate_bd
      end
      
      

      If I run this code in my plugin, it works just fine. Unfortunately, it also makes SketchUp unresponsive to other input, keeps the Ruby Console from updating, etc. So, I tried giving the code its own Thread:

      
      Thread.new do
        loop do             # Loop forever, handling files.
          ...
        end
      end
      
      

      This doesn't tie up SketchUp, but it doesn't work, either. In fact, it appears that the code in the thread never gets run at all. Comments? Clues? Suggestions?

      -r

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: PBI - emulate WebDialogs in a browser?

      I have some encouraging progress to report. I now have a proxy server, based on EventMachine, that works on Mac OS X 10.5.8 (Mac Pro).

      The server should be able to provide asynchronous communication between a SketchUp plugin and JavaScript code in any browser capable of handling WebSockets (eg, Chrome, Safari). See my wiki pages for more information:

      • http://cfcl.com/twiki/bin/view/Projects/SketchUp/WD_WoR_BrowserDialog - project overview
      • http://cfcl.com/twiki/bin/view/Projects/SketchUp/WD_WoR_BD_Server - server details

      I'm now getting ready to create some Ruby and JavaScript methods to emulate the WebDialog API. I'll report any substantial progress if and when it occurs...

      Meanwhile, I'd love to have someone try out the proxy server on something other than a Mac. Aside from letting me know about (and possibly resolve) portability issues, this could help me to create setup and usage notes for Windows, WINE, etc.

      -r

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Interest in a Networking Sockets Workaround

      Just wanted to note my interest in this effort. I'd love to have a reliable way to send and receive data on sockets.

      However, I'm curious why you're writing the server in C++. Is there some reason why it couldn't be written in Ruby?

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Would anyone like a developer's IRC channel?

      @unknownuser said:

      Well, nice idea! And if, somehow this would be made public on other environments, other than SCF, maybe it would attract more interested people.
      I logged-in today, but it was empty ๐Ÿ˜„

      Again, if everyone waits for the channel to fill up before they're willing to stick around, it never will. I've been on the channel for several days now; I just leave a session going. I may not be actively watching it all the time, but I'll certainly get back to anyone whose message I see.

      FYI, I also posted a note to sketchupruby@googlegroups.com; since we only want SketchUp developers, I'm not sure where else would be appropriate...

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: SF Bay Area Developer Workshop?

      We've had 50+ views of this topic, but only two positive responses. If you are interested, please say so (either publicly or privately; I don't care). That way, I'll know whether there's enough interest to start things rolling.

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Would anyone like a developer's IRC channel?

      The IRC channel has been up for a few days now, but we've had very little traffic. Meanwhile, we've had 140+ views of this topic, so it's clear that some folks think the idea might have merit.

      I think this is a "chicken and egg" situation: if everyone waits for the channel to catch on, it never will. So, if you're interested in having this resource available, please sign on for a few days, looking in from time to time.

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Need help with meta-attribute definitions

      I have updated the page substantially, but still need feedback, etc. C'mon, folks...

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: HP-Branded 3D Printers coming

      I see this tantalizing post from January 2010:

      @tig said:

      Here's my first go at a 'manifold' fixer... http://forums.sketchucation.com/viewtopic.php?p=218691#p218691 ๐Ÿค“

      After that, silence... TIG, did you pursue this to a working plugin? Are you planning to do so?

      FWIW, my naive thought is that it would be great to have a collection of "broken" models to be used in testing such a tool. Would it be hard to assemble a "starter set" of these?

      posted in Corner Bar
      RichMorinR
      RichMorin
    • RE: Would anyone like a developer's IRC channel?

      @krisidious said:

      Post by Krisidious on Sat Nov 13, 2010 9:38 pm
      I think you guys would like Vent better...http://www.ventrilo.com/

      Voice over IP certainly has its place, but I don't think this is one of them.

      First, this is an international community, many of whose members do not have English as their first language. So, they may find it easier (and less error-prone) to communicate via text.

      Second, a great deal of the material being discussed will be technical in nature and textual in format. Trying to dictate this over an audio link is not going to be fun (or productive).

      Finally, by using a textual medium, we can log conversations, search them, etc. We could not do this if we were communicating via voice.

      So, although I appreciate the suggestion (and welcome you to start up a voice-based forum, if you wish), I think I'll stick with IRC.

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Would anyone like a developer's IRC channel?

      Alternatively, Mac users can use Adium or Colloquy (I use the latter) to do IRC.

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • SF Bay Area Developer Workshop?

      I'd be willing to do the logistics for a Developer Workshop in the San Francisco Bay Area, if folks are interested in attending. Nothing fancy; just a quiet place and time to have informal discussions and presentations. If you're interested, please let me know...

      -r

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Would anyone like a developer's IRC channel?

      I have set up an IRC channel (#sketchup-dev on irc.freenode.net) for discussion of SketchUp development topics. I expect this to mostly be about Ruby, but other topics (eg, dynamic attributes) are also welcome. About the only thing that will cause banning is abusive behavior: MINSWAN (Matz is nice, so we are nice.)

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • Need help with meta-attribute definitions

      My cookbook page on meta-attributes is rather incomplete:

      • It may be missing some meta-attribute types.
      • Some meta-attributes aren't defined.

      Can anyone (eg, Scott <g>) give me a hand?

      http://cfcl.com/twiki/bin/view/Projects/SketchUp/DA_Meta_Attributes

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • Would anyone like a developer's IRC channel?

      I've been thinking about starting and running an IRC channel (eg, sketchup-ruby) for SketchUp Ruby developers. Before I commit to this, however, I thought I should know whether I'd be alone on it.

      I would also like to know if anyone else might be willing to help run it. let me know...

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • When (and why) might &quot;file_loaded?&quot; be needed?

      In some plugins I've perused, there is code like this:

      
      unless file_loaded?('MyPlugin.rb')
        UI.menu('Plugins').add_item('My Plugin')
        file_loaded('MyPlugin.rb')
      end
      
      

      I'm curious about when and why SketchUp might try to reload a plugin. Does anyone know the answer to this?

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • PBI - emulate WebDialogs in a browser?

      Although I've been able to use a browser (eg, Safari) to debug HTML, CSS, and JavaScript content stored in static files, I can't do this with dynamically loaded content. Nor can I test things that depend on communication between Ruby and JavaScript code.

      So, I'd like a way to emulate WebDialogs in a browser. My Partly-Baked Idea (PBI) goes something like this:

      1. Create a simple HTML/JS file for testing (eg, a header and a checkbox, where the checkbox is supposed to control the color of the header, via a Ruby round trip). Wrap the "location=" call in a JS method, for flexibility.

      2. Get the file working with a SketchUp plugin, using callbacks, etc.

      3. Get the file working with a simple web app, using (say) Rack or Sinatra.

      4. Find a way to emulate the needed parts of the web app under SketchUp.

      5. Fold the emulation code into the WebDialog class.

      Comments, clues, suggestions?

      -r

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Working around &quot;location=&quot;, for debugging

      @dan rathbun said:

      I was under the impression that the code block of show() and show_modal() did not work on the Mac.
      Has this been fixed on SU 8.x ??

      Dunno, in general, but a quick experiment worked for me. Then again, I was only setting a single variable.

      -r

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Working around &quot;location=&quot;, for debugging

      Here is the comment block I put in my code. I think it summarizes what I know about this issue. Comments welcome...

      
      # It's a bit tricky to determine whether this
      # method is running under SU or a web browser.
      # The first way I found, which is solid but
      # clunky, is to write a second copy of the HTML
      # file using a name such as DBG_main.html,
      # allowing this test to work;
      #
      #   document.documentURI.match(/DBG_/) ||
      #     (location = string);
      #
      # Adam Billyard (AdamB on SketchUcation) pointed
      # out that Safari puts some extra goo at the end
      # of the appVersion string.  So, here's a less
      # clunky (but possibly brittle) alternative;
      #
      #   navigator.appVersion.match(/533\.18\.5$/) ||
      #     (location = string);
      #
      # Thomas Thomassen (thomthom on SketchUcation),
      # pointed out that JavaScript code may be reliably
      # sent from a block attached to the show() or
      # show_modal() call, as;
      #
      #   wd.show_modal do
      #     wd.execute_script('env_is_webdialog = true;')
      #   end
      #
      # This allows the technique below to be used;
      #
      #   env_is_webdialog && (location = string);
      
      
      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Working around &quot;location=&quot;, for debugging

      Good catch! I had looked at the appVersion strings, but failed to notice the extra goo at the end of the Safari version.

      I'm not sure what you mean by "isn't the simplest thing to install a scheme handler that does nothing". Could you please give more details?

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • RE: Working around &quot;location=&quot;, for debugging

      As I understand it, there's no reliable way for the plugin code to know when the webdialog has been loaded, except to wait for a "location=..." message. And, if I try to send that message in the browser environment, I crash. So, I seem to have a "chicken and egg" problem. Am I missing something?

      posted in Developers' Forum
      RichMorinR
      RichMorin
    • 1 / 1