For command line options see the RapCAD manual
Basic Values
Number
a=1; b=5.1; c=-0.6;
Text
a="Hello World!";
Boolean
a=True; b=False;
Vector
In RapCAD commas are not allowed at the end of a vector because it it often a sign of error.
a=[,10,10]; // means [undef,10,10] b=[10,10]; // means [10,10] c=[10,,10]; // means [10,undef,10] d=[10,10,]; // syntax error use [10,10,undef] <1>
-
Since index out of bounds errors are not desired, RapCAD will treat vectors containing less elements than expected as though the elements exist but are undefined. Thus if we expect a 3D vector, but are given a 2D vector such as [10,10] RapCAD will treat this as [10,10,undef] you can therefore treat [10,10,undef] as synonymous to [10,10] so in the example above you could simply write d=[10,10] if you prefer.
Range
a=[1:5]; // 1,2,3,4,5 b=[0:2:10]; // 2,4,6,8,10
3D Primitives
RapCAD supports a set of built in 3D primitives. The primitives are modules that take arguments which specify the size and shape of the primitive. A module is instanciated by writing its name followed by parenthesis which enclose the arguments. Since it is also a statement it must be followed by a semicolon.
Cube
cube(size,center); cube(s,c);
Sphere
sphere(radius); sphere(r);
Cylinder
RapCAD suports legacy r1 and r2 parameters on cylinder. The Cone module is more appropriate for drawing cones.
cylinder(radius,height,center); cylinder(r,h,c);
Cone
cone(radius1,radius2,center); cone(r1,r2,c);
Prism
prism(height,sides,apothem); prism(height,sides,radius);
Polyhedron
RapCAD supports a legacy triangles parameter, but the name is a bit misleading since polygons with more than three points can be specified using this parameter. The name surfaces was chosen in preference to polygons so as not to have a single letter name conflict with points.
polyhedron(points,surfaces); polyhedron(p,s);
2D Primitives
Square
square(size,center); square(s,c);
Circle
circle(radius); circle(r);
Polygon
RapCAD supports a legacy parameter paths this however conflicts with the single letter parameter name points.
polygon(points,lines); polygon(p,l);
Polyline
polyline(points);
Bezier Surface
bezier_surface(mesh);
Control modules
Echo
The echo module allows you to debug values that are evaluated as part of your script. You can pass more than one argument to echo and it will be output to the console. Named arguments are allowed but the names will not be echo’ed.
echo(53+9); echo([32,24,10]); echo(a=1,b=2);
Bounds
bounds()cube(10);
Child
child();
Operations
Union
union() { module1(); module2(); }
Group
group() { module1(); module2(); }
Difference
difference() { module1(); module2(); }
Symmetric Difference
symmetric_difference() { module1(); module2(); }
Intersection
intersection() { module1(); module2(); }
Minkowski Sum
minkowski() { module1(); module2(); }
Glide
glide() { module1(); module2(); }
Hull
hull() { module1(); module2(); }
Sub Division
subdiv() module1();
Transformations
Linear Extrude
linear_extrude(h=10) square([10,10]);
Mirror
mirror() translate([0,20,0]) cylinder(r=5,h=10);
Offset
offset() module1();
Rotate
rotate([0,0,90]) module1();
Scale
scale([0.1,0.1,0.1]) module1();
Shear
shear() module1();
Translate
translate([0,20,0]) module1();
Compiling
The following instructions will allow you to compile RapCAD from source on various platforms.
Prerequisites
The source code is hosted in a git repository so you might want to install git first
sudo apt-get install git-core
Linux
sudo apt-get install g++ libcgal-dev libqt4-dev bison flex
wget ftp://anonymous:anonymous@ribbonsoft.com/archives/dxflib/dxflib-2.2.0.0-1.src.tar.gz tar -xzf dxflib-2.2.0.0-1.src.tar.gz && cd dxflib-2.2.0.0-1.src && sed "s/<string>/<string.h>/" -i src/*.h && CFLAGS=-fPIC ./configure --prefix=/usr && make depend && make && gcc -shared -Wl,-soname,libdxflib.so.2 -o lib/libdxflib.so.2.2.0 src/*.o && sudo make install && sudo install -m 644 lib/libdxflib.so.2.2.0 /usr/lib && sudo ldconfig -n /usr/lib
git clone git://git.rapcad.org/rapcad cd rapcad && qmake && make
Windows
MinGW
-
Download the MinGW Automated installer package mingw-get-inst-20111118.exe
-
Check the C++ compiler checkbox.
-
Check the msys checkbox
-
Install to C:\MinGW\
Qt (MinGW)
-
Download Qt installer qt-win-opensource-4.8.0-mingw.exe
-
Ignore warning about win32api version.
-
Install to default location C:\Qt\
CMake
-
Download CMake installer cmake-2.8.7-win32-x86.exe
-
Check the Add cmake to the system path for the current user checkbox
-
Install to default location C:\Program Files\CMake 2.8
Boost
-
Download Boost source boost_1_49_0.zip
-
Extract all to C:\ (sources will end up in C:\boost_1_49_0\ )
-
Use the QT Development Command Prompt
Start→Program Files→Qt by Nokia v4.8.0 (MinGW OpenSource)→QT 4.8.0 Command Prompt
cd C:\boost_1_49_0\ bootstrap.bat .\bjam toolset=gcc release thread
https://gforge.inria.fr/frs/download.php/30386/CGAL-4.0-Setup.exe
|
Note
|
CGAL-4.0-Setup.exe is not a binary distribution, just an installer that installs the source. |
-
No need for CGAL Examples and Demos
-
Make sure mpfr and gmp precompiled libs is checked
-
Install to C:\CGAL-4.0\
-
Make sure CGAL_DIR environment checked.
-
Use the QT Development Command Prompt
Start→Program Files→Qt by Nokia v4.8.0 (MinGW OpenSource)→QT 4.8.0 Command Prompt
set PATH=%PATH%;"C:\Program Files\CMake 2.8\bin" cd "C:\CGAL-4.0\" cmake -G"MinGW Makefiles" -DBOOST_ROOT="C:\boost_1_49_0" -DBOOST_LIBRARYDIR="C:\boost_1_49_0\bin.v2\libs\thread\build\gcc-mingw-4.6.2\release\threading-multi\" . make
ftp://anonymous:anonymous@ribbonsoft.com/archives/dxflib/dxflib-2.2.0.0-1.src.tar.gz
Mac OS X 10.6.2
Xcode 3.2
Register with apple and download Xcode 3.2.2. Install the package accepting the default options.
MacPorts
Download the MacPorts Installer. Install the package accepting the default options.
sudo port install cgal qt4-mac
tar -xzf dxflib-2.2.0.0-1.src.tar.gz && cd dxflib-2.2.0.0-1.src && ./configure --prefix=/opt/local && make depend && make && sudo make install
qmake CONFIG+=official make cp -R /opt/local/lib/Resources/qt_menu.nib rapcad.app/Contents/Resources/ macdeployqt rapcad.app -dmg hdiutil internet-enable -yes rapcad.dmg