sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Running Sketchup as a service with sinatra

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 4 Posters 941 Views 4 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.
    • R Offline
      ryu
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • tt_suT Offline
        tt_su
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • R Offline
          ryu
          last edited by

          On the Mac I get the model named as expected. But on Windows, the browser sits and waits for Sinatra to respond.

          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            Have you checked the Ruby Console when you run it for errors?

            1 Reply Last reply Reply Quote 0
            • R Offline
              ryu
              last edited by

              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.

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

                @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 ??

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • R Offline
                  ryu
                  last edited by

                  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=4567

                  These 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

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    ryu
                    last edited by

                    This now works in windows Sketchup 2014. Probably ruby 2.x.x solved the problem.

                    -Robert

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

                      SU used to modify set, since ruby 2 it dosen't
                      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