I would just like to add that I am also plagued by this bug. Any new info or workarounds?
Posts
-
RE: Components slow AFTER purging / user profile
-
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
-
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
-
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.
-
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#p326273Also, 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
-
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
-
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?
-
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.
-
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.
-
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.
-
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.
-
Something I haven't thought of.
Thanks,
-Mike -
-
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.
-
RE: Quick theoretical question
it was STEP, I believe. is the xml simplier?
-
RE: Quick theoretical question
@unknownuser said:
I hope you don't mind if I summarize what you said into a few sentences and slide it right into my thesis
no prob.
as for release... I'd love to eventually share it with the world. Maybe for a small price, maybe not. That depends on what is going to be necessary on the server side. I'm a lowly full-time architect with no formal code training and no real free-time outside of work so dedicating serious time to it is difficult. That said, improving the process by which we design has sort of become my passion. Providing the best tools is imperative to creating the best design process. In the building industry with so many disciplines involved in the design process, I believe the tools must be as collaborative as possible. I think that is where software is going and that is what I'd like to create.
-
RE: Quick theoretical question
@unknownuser said:
spectators can watch the contest in realtime via an O3D plugin.
That is also something that I want it to do. I've been trying to familiarize myself with WebGL after is saw the Google Body Browser project.
http://bodybrowser.googlelabs.com/body.html#
(you need chrome, or some of the nightly betas for the other major browsers, for it to work. no IE). -
RE: Quick theoretical question
I think you've got the idea. pretty exciting to think about what could be possible if you got 10's if not 100's of people in on model environment creating something together in real-time. I think it could be really amazing.
I am trying very hard to stay away from the first method you suggest. Revit uses a similar method of "saving to central" and I find it not very collaborative at all. The key here is "real-time." so your second methods it closer to the method I am exploring. I was going to use the XML collada approach but from what I can tell there is sketchup info that is not created in the collada file i.e. layers, attributes, pages, styles, etc. (layers being the big deal breaker). If I'm wrong about that, let me know.
The other approach I considered was plugging into an IFC file as my goals are for architecture. However, studying the IFC documentation gave me a headache so I gave up. Right now, I'm creating my own simple model database that uses mostly hashes to recreate and record changes to the model. all clients have this mega hash, when observers fire, the client tells the server, the server updates the hash and sends the changes to all other clients to update their local hash and the local model.
-
RE: Quick theoretical question
Theoretically, sure. I can imagine a world where multiple people can collaborate on a single model across the internet. I'm playing with that very idea right now. I'm not using php, mysql, or any webdialogs (yet). I use a simple UDP socket server setup similarly to how it would be for a multi-player video game like quake or call of duty. The sketchup sessions shares information back and forth through a server to stay in sync. The following link is a very early proof of concept that shows the view location being shared between two Sketchup sessions.
The view is one thing but sharing entities does requires a lot more work. Not impossible, in my opinion, just more work.
good luck with the thesis.
-Mike
-
RE: Clients <--> Server Communication (Sockets?)
also, the whole mswin32 vs mingw32. I tried to use mswin32 but without a one click installer I think getting it installed correctly with rubygems loaded had me stumped. I got into ruby through sketchup so the whole "full" ruby stuff is new to me. The gem thing was a real issue when I was trying to figure this out. However, now that I've decided to not use any gems, maybe I'll look back into getting the ruby install to be mswin32.
The problem for another day is that the only thing I'm using from ruby 1.8.6 is socket.so but it much have ties to other ruby resources so if i try to directly use it, it's a no go. In the end, I need to figure out how to package up the resources I want to utilize without having to make every user install the full ruby.
-
RE: Clients <--> Server Communication (Sockets?)
I never really did figure it out completely. right now I'm using a dumbed down version of your !loadpath.rb it looks like this:
begin # add the standard lib path $LOAD_PATH << "C;/Ruby186/lib/ruby/site_ruby/1.8" $LOAD_PATH << "C;/Ruby186/lib/ruby/site_ruby/1.8/i386-msvcrt" $LOAD_PATH << "C;/Ruby186/lib/ruby/site_ruby" $LOAD_PATH << "C;/Ruby186/lib/ruby/1.8" $LOAD_PATH << "C;/Ruby186/lib/ruby/1.8/i386-mingw32" $LOAD_PATH << "C;/Ruby186/lib/ruby/gems/1.8/gems/cool.io-1.0.0/lib" $LOAD_PATH << "C;/Ruby186/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib" $LOAD_PATH << "C;/Ruby186/lib/ruby/gems/1.8/gems/iobuffer-1.0.0/lib" $LOAD_PATH << "C;/Ruby186/lib/ruby/gems/1.8/gems/rdiscount-1.6.5/lib" $LOAD_PATH << "." $LOAD_PATH.uniq! # # print LOAD PATHS to console # (May not print during Sketchup startup!) Sketchup.send_action('showRubyPanel;') UI.start_timer(1,false) { puts "\nLOAD PATHS;\n" $LOAD_PATH.each {|x| puts "#{x}\n"} puts "\n\n" } end
As you can see, I pretty much just load in the entire phone book. Works fine for sketchup 8 but not at all for sketchup 7. While I'm sure I can modify something to get it working in 7, at the moment I am relying on a UI.start_timer set to less than one so I think I'm stuck with 8 only anyway.
also, as you can see I tried to play with some ruby gems but never had any success getting them to work in sketchup.
At the end of the day I want to be able to distribute this plugin to other people. I hope I'm not relying too much on the full ruby install.
-
RE: Clients <--> Server Communication (Sockets?)
It's been awhile. Sorry for the slow-to-update response. I wish I had more time to play/work on this stuff. I just wanted to give an update on my progress. After trying several different methods, the method I am using for bi-direction communication between sketchup sessions is using the socket.so ruby library. I've created a udp client program for sketchup that can connect to a ruby console server application. Multiple sketchup sessions can connect to the server and connected clients are managed in a client list by the server. Data can be transmitted from a sketchup session to the server and them broadcasted to all connected clients. As a test, I transmit the view location continuously so every session knows where my the viewpoints are of the other sessions. It works! I'm sure it's inefficient and sloppy but at least it works and doesn't seem to have significant impact on modeling performance.
My next steps (and probably I'll start a new thread if I have questions) are figuring out the best way to thread it so the server can run independent to the sketchup loop. Right now I am using the UI.start_timer to check for new messages every 1/10th of a second. Now that the timer accepts durations less than 1 second this is working well in sketchup 8 but probably wont in 7 and earlier.
The big elephant in front of me is non persistent entity_ids. I knew this going into it but figured I'd work around it. I think it's time to once and for all create a work around for entity identification and lookup. Without going deepb into it, I plan on creating and updating a hash table that will link entities to an id stored in an attrib dictionary that is persistent. I want to figure that out independent to my project because I know there are others frustrated with entity memory and could benefit from a working solution.
That's it. I'm one step closer to sketchup as a multiplayer video game platform. only several thousands more to go.
-
RE: [Code] Ruby LOAD PATHs script (Win32) : ver 3.0.1
Wow! So helpful! I'm going to have to absorb this all for a little while. Thanks.
-
RE: Clients <--> Server Communication (Sockets?)
Jim, that's Interesting. At first I couldn't replicate your require 'socket' result but then I tried in Sketchup 8 and it worked. "RUBY_VERSION" in SU7 says "1.8.0" and in SU8 "1.8.6" Is that why it doesn't work in 7? I have 1.9.2, 1.8.7, and 1.8.6 all one-click installed and unmodified.
I'm excited to trying to play with the ruby socket.so. Is there any reason to think that my goals to create a bi-directional client/server communication link will NOT be possible with ruby sockets?
Dan, most of what you said when straight over my head. i386-mingW32 vs i386-mswin32 is beyond me at the moment. I can say however, that I use your !loadpaths.rb which adds the i386-mswin32 directory to the $LOAD_PATH and when I "require 'C:/ruby186/lib/ruby/1.8/i386-mingw32/socket'" it returns true. I have not modified any files. Are you recommending that I uninstall my current ruby build and get the mswin32 version? Should I stick with 1.8.6?
Thanks again.
-
RE: Clients <--> Server Communication (Sockets?)
Thanks Dan and Thomthom,
I 'm going to take both of your advice. I'll look into Win32Utils and I'll stay away from Webdialogs. Is the SKsocket thing not worth exploring at all?
Dan, while cross-platform support would be nice, I'll take what I can get. Windows only is ok.
I'll report back if I figure anything out.