Running Sketchup as a service with sinatra
-
Hi,
I am looking into providing sketchup as a service through sinatra. I was able
to load the sinatra gem into sketchup. I created just a couple of routes:require 'rubygems' require 'sinatra/base' class MyTest < Sinatra;;Base get '/test' do "thankyouverymuch" end get '/model' do Sketchup.active_model.name end end MyTest.run!
From a browwer I was able to get http://localhost:4567/model to respond with the model name,
but this only worked on the mac version. I was not able to get it to work on the windows version. I am using the latest version 8. Anyone try this before? Why does the windows version behave differently?-Robert
-
Are you getting errors? Or is the return value unexpected? Is the model saved? If it isn't then Model.name returns an empty string.
-
On the Mac I get the model named as expected. But on Windows, the browser sits and waits for Sinatra to respond.
-
Have you checked the Ruby Console when you run it for errors?
-
I see no errors in the windows ruby console. One difference is that on the mac, after I run "MyTest.run!", the cursor becomes "busy". On the windows, after I run "MyTest.run!", sinatra does not start up. However, if I run "irb" on windows and load the same test, sinatra works.
-
@ryu said:
Why does the windows version behave differently?
MS Windows machines do not come "out of the box" with Ruby installed. Mac machines DO.
Did you install Ruby on the Windows machine and add the paths to it's library directories onto the
$LOAD_PATH
array ?? -
Hi,
Yes, on windows, I installed ruby187, replaced the msvcrt-ruby18.dll, and updated the $LOAD_PATH. The sinatra gem loads fine. Here is a snippet from the ruby console
("try.rb" is the ruby code shown in my first post):load "./try.rb"
C:/ruby187/lib/ruby/1.8/set.rb:86: warning: method redefined; discarding old size
C:/ruby187/lib/ruby/1.8/set.rb:89: warning: discarding old length
C:/ruby187/lib/ruby/1.8/set.rb:92: warning: method redefined; discarding old empty?
C:/ruby187/lib/ruby/1.8/set.rb:97: warning: method redefined; discarding old clear
C:/ruby187/lib/ruby/1.8/set.rb:117: warning: method redefined; discarding old to_a
C:/ruby187/lib/ruby/1.8/set.rb:157: warning: method redefined; discarding old include?
C:/ruby187/lib/ruby/1.8/set.rb:193: warning: method redefined; discarding old each
C:/ruby187/lib/ruby/1.8/set.rb:219: warning: method redefined; discarding old delete
true
MyTest.run!
[2013-09-03 17:26:03] INFO WEBrick 1.3.1
[2013-09-03 17:26:03] INFO ruby 1.8.7 (2011-06-30) [i386-mingw32]
== Sinatra/1.4.3 has taken the stage on 4567 for development with backup from WEBrick[2013-09-03 17:26:03] INFO WEBrick::HTTPServer#start: pid=6088 port=4567These are the same messages I get on the MAC. The MAC sketchup cursor then becomes
a "spinning wheel" and sketchup responds to http gets.On the PC, sketchup does not go into any "busy" mode, and sketchup does not respond to http gets.
Thanks for your help.
-Robert
-
This now works in windows Sketchup 2014. Probably ruby 2.x.x solved the problem.
-Robert
-
SU used to modify set, since ruby 2 it dosen't
john
Advertisement