How to Connect SimTools to SketchUp


SimTools can be used to animate a model in
SketchUp. What you need additionally is SketchyPhysics to draw joints and motors in your model. I wont go into the details of how to draw a model in SketchUp/SketchyPhysics. There are lots of better tutorials available on Internet. (Although I have to admit SketchyPhysics is less than intuitive and sometimes a pain.)

absatz

Preparing the Model

Once you have your model, make sure it moves as expected with the sliders and save a copy.

Sliders

Select one of your servos and click on “UI” to show the SketchyPhysics Inspector:

UI

Under “Controller” you will find something like “slider(‘servo4205’)”. Replace this with “$axis1”. This is our new global variable, that will be used to drive the servo instead of the slider. Repeat for all servos and replace the slider names with “$axis2”, “$axis3”, etc. When all done the SketchyPhysics Control Panel should be empty (or at least no liders for your servos) when clicking Play/Pause. Save the model and close SketchUp.

Preparing SimTools

In GameEngine setup your interface to Output Type: NET. When running GameEngine and SketchUp on the same computer enter 127.0.0.1 as IP address (otherwise the IP address of the PC that runs SketchUp) and Port 3157. Output – Bit Range shall be 8 and Decimal. In the Interface – Output field enter the axis you want to assign to the servos in SketchUp, separate the axis with “;”. Then click Save.

SimTools_Interface

Here my axis settings for the model attached:
Axis Assignments

Preparing SketchUp

Now to send the data from SimTools to SketchUp we’re going to use the Ruby API of SketchUp. Again, I’m not going into the details, as there is plenty of material available on the net. What you need though is a copy of socket.so of Ruby version 1.86 as this is what SketchUp works with. Other versions most probably will not work. Put this file into the SketchUp plugins folder (C:\Program Files (x86)\Google\Google SketchUp\Plugins). Create a text file in the same folder with the ending .rb. Copy the following code into this text file and save it:

Code:
require 'socket.so'
socket = UDPSocket.new
socket.bind("127.0.0.1", 3157)
timer_id = UI.start_timer(0.01, true) {
    message, sender = socket.recvfrom_nonblock(100)
    message1, message2, message3 = message.split(";")
    $axis1 = message1.to_f / 256.0
    $axis2 = message2.to_f / 256.0
    $axis3 = message3.to_f / 256.0
}

Get the fun

If not done already start up GameManager and your game of choice. Check if everything works to your satisfaction and open the SketchUp model. The Ruby script is automatically loaded at the start. So click on Play/Pause and see your simulator model dancing when driving your car!

Easy, isn’t it?

If you want to try immediately I have attached a file containing a SketchUp model and the Ruby script to the resources. You also need to install SketchyPhysics from here.


Thanks to James Bradwell, who has inspired me to set up SketchUp with SimTools!

Written by

"Enthusiastic Sim-Racer from the north of germany. I write here about web development, hardware, software and latest motion simulator technologies."