- install ruby and devkit as in Compile C++ plug-in for Sketchup.
- open a shell window with DevKit/msys.bat
- run the command
- gem install clipper
- copy the file clipper.so to the sketchup plugins directory - in my case i copied C:\Ruby187\lib\ruby\gems\1.8\gems\clipper-2.9.0\lib\clipper.so to C:\Program Files\Google\Google SketchUp 8\Plugins
- test by running the following ruby commands in the sketchup ruby console
require 'clipper'
a = [[0, 0], [0, 100], [100, 100], [100, 0]]
b = [[-5, 50], [200, 50], [100, 5]]
c = Clipper::Clipper.new
c.add_subject_polygon(a)
c.add_clip_polygon(b)
c.union(:non_zero, :non_zero).inspect
- the result should be
- [[[100.0, 0.0], [100.0, 5.0], [200.0, 50.0], [100.0, 50.0], [100.0, 100.0], [0.0, 100.0], [0.0, 50.0], [-4.999999, 50.0], [0.0, 47.8571432653061], [0.0, 0.0]]]
August 12, 2011
Install rbclipper in Sketchup 8
Sketchup doesn't support ruby gems. In some cases it is possible to move the content of a gem into a Sketchup installation to use it. I installed the excellent Clipper library by Angus Johnson. Mike Owens have made a ruby binding rbclipper, that I installed like this:
Compile C++ plug-in for Sketchup
Sketchup crashes when loading a C++ ruby extension. As Dan Rathbun says in for example http://forums.sketchucation.com/viewtopic.php?f=180&t=34735#p306377, you have to compile the extension using ruby 1.8. This solved my problem - I had used ruby 1.9 when I experienced my crashes.
I failed to find a complete how-to for successfully compiling an extension for Sketchup, so here is how I did:
I failed to find a complete how-to for successfully compiling an extension for Sketchup, so here is how I did:
- I used Sketchup 8.0.4811 in this how-to
- installed Ruby using RubyInstaller-1.8.7-p352.exe to c:\
- Installed Development Kit using DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe to c:\ including the post installation steps.
- Found the page http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html and downloaded http://www.rubyinside.com/files/extension-code.tar.gz from the link in the article.
- unpack the extension-code.tar.gz into the DevKit folder resulting in the folder module-experiment
- run DevKit/msys.bat to get a shell window, and in that shell do:
- cd /module-experiment/MyTest
- ruby extconf.rb
- make
- now you should have mytest.so in the current directory
- copy mytest.so to the sketchup Plugins folder - in my case C:\Program Files\Google\Google SketchUp 8\Plugins
- start sketchup
- use menu Window/Ruby Console
- in the ruby console edit field do as the rubyinside.com/how-to... page says:
- require 'mytest'
- include MyTest
- puts test1
- the last command should print 10
Subscribe to:
Posts (Atom)