sketchucation logo sketchucation
    • Login
    1. Home
    2. mtalbott
    ℹ️ 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 5
    • Posts 30
    • Groups 1

    mtalbott

    @mtalbott

    10
    Reputation
    1
    Profile views
    30
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online
    Age 44

    mtalbott Unfollow Follow
    registered-users

    Latest posts made by mtalbott

    • RE: Components slow AFTER purging / user profile

      I would just like to add that I am also plagued by this bug. Any new info or workarounds?

      posted in Newbie Forum
      M
      mtalbott
    • UI.start_timer() is the new while

      One thought and one question...

      Thought: Now that in Sketchup 8 UI.start_timer() works with factions of a second, I've found it more stable, and more fun, to make any iterative loop with UI.start_timer. By doing this, you give control back to sketchup every cycle so you never get the white screen and the program never locks. Of course it is much slower, but by never locking up the program it even allows me to keep working while whatever script is running. My most current use is on a draping tool that approximates a complex topography with a simpler grid. It's fun to just watch it iterate over the surface and refine the points. Another simple example would be the "drop at intersection" tool. It is easily modified to refresh after each drop. It's sort of like a progress bar that you can see in the model. Just curious what peoples thoughts are on the technique. Before start_timer worked correctly I would do a similar thing with an animation class and next_frame.

      Question: In your experience, what is the smallest amount of pause time you can use with UI.start_timer to give sketch-up enough time to properly do it's thing and do you see a lower limit where there is no appreciable difference?

      -Mike

      posted in Developers' Forum
      M
      mtalbott
    • RE: Best way to recreate the model database?

      @jim said:

      How's the project coming along?

      Unfortunately, it's not coming along very much at all. just been too busy to code (which is my hobby, not my job). The initial goal was to make a server-base sketchup environment so that multiple people could work on a model at the same time. However, my eyes got bigger than my abilities and I started dreaming of a completely new way to collaborate, document, and communicate 3-dimensional information. I got a little overwhelmed when I starting looking into webGL and thought that it would be amazing if there would be a way to put sketchup modelings into a browser webGL viewer similar to google's body browser:http://bodybrowser.googlelabs.com/body.html#. Since then I am cooling the programming jets to write a white paper on the future of architectural documentation and what the technology required for an all-digital design/build environment might look like.

      Thanks for the advice on my previous post. I will be getting this project going again hopefully very soon.

      -Mike

      posted in Developers' Forum
      M
      mtalbott
    • RE: UDP Socket and Threading in API

      As Dan pointed out UI.start_timer works pretty good with UDP. Here's how I'd write it:

      
      require 'socket'
      serverSocket = UDPSocket.new
      serverSocket.bind("127.0.0.1", 3157)
      timer_id = UI.start_timer(0.1, true) {
        begin
          data = socket.recvfrom_nonblock(100)
          new_message = true
        rescue Errno;;EWOULDBLOCK
          new_message = false
        rescue Errno;;ECONNRESET
          new_message = false
          UI.stop_timer @timer_id
          break
        end
        if new_message == true
          UI.messagebox(data)
        end
      }
      
      

      The major different is the UI.start_timer in place of the "Thread" and "Loop" in your example. You'll also see that it uses .recvfrom_nonblock with some error catching instead of just .recvfrom. This is because sketchup will hang if nothing is sent to the socket. If you're sure that there will be a constant stream of data you might be able to get it to work with blocking.

      posted in Developers' Forum
      M
      mtalbott
    • RE: UDP interface

      ben,

      I just posted a simple example of a UDP interface here:
      http://forums.sketchucation.com/viewtopic.php?f=180&t=31545&start=15#p326273

      Also, before I started working on UDP stuff I wrote a ruby script for the wiimote and sketchup to do head tracking similar to what Johny Lee was doing years ago.http://johnnylee.net/projects/wii/

      Back when I wrote it, I was using GlovePIE with an Output to file script that I think GlovePIE came with. In sketchup I was just constantly seeking to the end of that file to get the most recent wiimote data. It worked but I never felt it was the best way to do it.

      -Mike

      posted in Developers' Forum
      M
      mtalbott
    • RE: Interest in a Networking Sockets Workaround

      back to the original post... since there's seems to be some interest in networking sockets for sketchup. I'll tell you my findings so far...

      While, I would also be interested in a C++ networking bridge, I have had success using ruby sockets in sketchup 8 on windows 7. This might be easier for people who only know ruby. Ruby sockect class comes from the socket.so file found in the 1.8.6 full ruby install. Once you have that file, just require it in your code:

      require 'socket'
      

      as you can probably guess I copied the socket.so file to the /plugins directory. That seems to work fine.

      For my example there are two ruby apps. One will run in the ruby console (outside of sketchup) I'll call it the "server" and the other is sketchup itself, I'll call that the "client".

      Next, I initialize a UDPsocket object and bind it to an ip and port. For my purposes I am using UDP instead of TCP because I need to send lots of little messages very often and I don't care if one gets lost. If you needed to do TCP with ruby, it can do that too.

      socket = UDPSocket.new
      socket.bind(ip, port)	
      
      

      "ip" is your localhost ip address, "localhost" will work if it's just local communication. and "port" can be whatever port you want as long as it's available. I use 2000 for the server app and I use 0 for the client which causes it to generate a dynamic port number.

      On the server side, I setup a loop to check for incoming messages, send any new messages, and repeat:

      while connection == true
        begin
          message = socket.recvfrom_nonblock(maxlen)
          # messages look like this;
          # ["message string", ["AF_INET", 4913, "localhost", "127.0.0.1"]]
          # the second item of the array is the address information of the sender
          client_ip = message[1][3]
          client_port = message[1][1]
          new_message = true
        rescue Errno;;EWOULDBLOCK # fires if there is no new message
          new_message = false
        rescue Errno;;ECONNRESET # fires if something goes wrong on the client side.
          new_message = false
          connection = false
          break
        end
        if new_message == true
          # do something here with the incoming message and send a reply
          socket.send("got it, thanks.", 0, client_ip, client_port)
        end
      end
      

      As you can see, I had to do some error catching on the receive. This is the only way I've figured out how to get non-blocking to work. I also left out the "do something" part to keep it simple.

      On the client/Sketchup side, I make a similar loop but this time I have to use a UI.start_timer instead of a while statement because I need to give control back to sketchup each loop so that sketchup can keep doing it's thing:

      timer_id = UI.start_timer(0.1, true) {
        begin
          message = socket.recvfrom_nonblock(maxlen)
          new_message = true
        rescue Errno;;EWOULDBLOCK # fires if there is no new message
          new_message = false
        rescue Errno;;ECONNRESET # fires if something goes wrong on the server side.
          new_message = false
          UI.stop_timer @timer_id
          break
        end
        if new_message == true
          # do something here with the incoming message
        end
        if outgoing_message != nil
          socket.send(outgoing message, 0, server_ip, server_port)
        end
      }
      

      Couple notes here. One, I have the timer set to 1/10th of a second. Haven't really tested other speeds but this seems to work pretty good. Two, "outgoing_message" for me is something created by observers. Three, I just hard code in the server_ip, and server_port("127.0.0.1", 2000). this won't change in my application.

      In this example I am sending useful information to the server, not the other way. you can reverse it or go both ways. I have also left out any acknowledgment systems you might need to confirm the other side got what you sent. I believe TCP has this built in. UDP over the internet is unreliable but if it's just meant to be local, the packet gets there pretty much every time.

      Anyway, just thought I would share. I'm sure there are probably some benefits to a C++ solution but I only know ruby so I'm stuck working with what I've got. If anyone looks at this and thinks this it completely wrong, let me know. I'm still learning.

      -Mike

      posted in Developers' Forum
      M
      mtalbott
    • Best way to recreate the model database?

      Hi, all. I'm working on a script that has to recreate the sketchup model database outside of sketchup (ruby console app on a remote server). I am struggling with the best way to do it for best performance/flexibility. one constraint is that I can only communicate with the external app through Strings. Also, I am not using the import/export SDK because this is for real-time communication so I am using observers to notice changes and update the external model several times a second. The external model is for many things e.g. versioning/history records, multiple users, complex visibility controls, browser viewer with webgl, and a few others.

      how would you do it?

      1. Hash: The way I'm doing it right now is with nested hashes. a single message might look like this {time.now =>{"edge" => {id_number => {start_pt, end_pt}}}}. I pass it back and forth with .inspect and eval() to make it a string. I then take the new message and use it to .update a mega hash overwriting old info or adding new info. it works but the hashes are several levels deep and I don't know if there are going to be performance issues.

      2. JSON: this would be the same as a hash just modifying the string to be JSON. The benefit of this might be using it with existing webGL libraries or anything web related but i don't really know.

      3. MySQL or some other database: with a real database I could organize the information better in tables but I don't know if queries would be faster or slower than looking up in a hash. Also, it's just one more layer of technology to use/learn.

      4. XML: I could write changes out to some XML format like collada or IFC. not sure how I would update the xml but maybe it's possible. Also, worried about quick look-ups with XML.

      5. Something I haven't thought of.

      Thanks,
      -Mike

      posted in Developers' Forum
      M
      mtalbott
    • RE: Plane from current view

      I have a similar workflow to what your describing but I use photo match and no ruby scripts. Set the view you want, save it at the screen resolution, edit it, then start a Photo Match session using the new image. Everything should line up perfectly as long as nothing has changed. Finally, just project the photo onto the elements of the model using the option on the Photo Match Dialog.

      posted in Developers' Forum
      M
      mtalbott
    • RE: Quick theoretical question

      Super helpful, as always. Thanks.

      posted in Developers' Forum
      M
      mtalbott
    • RE: Quick theoretical question

      it was STEP, I believe. is the xml simplier?

      posted in Developers' Forum
      M
      mtalbott