openscad/README.md

246 lines
9.8 KiB
Markdown
Raw Permalink Normal View History

2013-12-24 15:50:25 +04:00
[![Travis CI](https://api.travis-ci.org/openscad/openscad.png)](https://travis-ci.org/openscad/openscad)
2014-07-18 00:27:34 +04:00
[![Coverity Status](https://scan.coverity.com/projects/2510/badge.svg)](https://scan.coverity.com/projects/2510)
2015-01-05 04:10:37 +03:00
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/openscad/openscad/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
2013-05-14 04:53:20 +04:00
2012-05-08 02:00:31 +04:00
# What is OpenSCAD?
2012-07-01 00:42:51 +04:00
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=openscad&url=http://openscad.org&title=OpenSCAD&language=&tags=github&category=software)
OpenSCAD is a software for creating solid 3D CAD objects. It is free software
and available for Linux/UNIX, MS Windows and Mac OS X.
Unlike most free software for creating 3D models (such as the famous
2012-05-07 22:27:45 +04:00
application Blender) it does not focus on the artistic aspects of 3D modeling
but instead on the CAD aspects. Thus it might be the application you are
looking for when you are planning to create 3D models of machine parts but
pretty sure is not what you are looking for when you are more interested in
creating computer-animated movies.
2012-05-07 22:27:45 +04:00
OpenSCAD is not an interactive modeler. Instead it is something like a
3D-compiler that reads in a script file that describes the object and renders
the 3D model from this script file (see examples below). This gives you (the
2012-05-07 22:27:45 +04:00
designer) full control over the modeling process and enables you to easily
change any step in the modeling process or make designs that are defined by
configurable parameters.
2012-05-07 22:27:45 +04:00
OpenSCAD provides two main modeling techniques: First there is constructive
solid geometry (aka CSG) and second there is extrusion of 2D outlines. As data
exchange format format for this 2D outlines Autocad DXF files are used. In
2012-05-07 22:27:45 +04:00
addition to 2D paths for extrusion it is also possible to read design parameters
from DXF files. Besides DXF files OpenSCAD can read and create 3D models in the
STL and OFF file formats.
# Getting started
2012-05-08 05:21:01 +04:00
You can download the latest binaries of OpenSCAD at
<http://www.openscad.org>. Install binaries as you would any other
software.
2012-05-08 05:21:01 +04:00
When you open OpenSCAD, you'll see three frames within the window. The
left frame is where you'll write code to model 3D objects. The right
frame is where you'll see the 3D rendering of your model.
Let's make a tree! Type the following code into the left frame:
cylinder(h = 30, r = 8);
2012-05-08 05:21:01 +04:00
Then render the 3D model by hitting F5. Now you can see a cylinder for
the trunk in our tree. Now let's add the bushy/leafy part of the tree
represented by a sphere. To do so, we will union a cylinder and a
sphere.
union() {
cylinder(h = 30, r = 8);
sphere(20);
}
2012-05-08 05:21:01 +04:00
But, it's not quite right! The bushy/leafy are around the base of the
tree. We need to move the sphere up the z-axis.
union() {
cylinder(h = 30, r = 8);
translate([0, 0, 40]) sphere(20);
}
2012-05-08 05:21:01 +04:00
And that's it! You made your first 3D model! There are other primitive
shapes that you can combine with other set operations (union,
intersection, difference) and transformations (rotate, scale,
translate) to make complex models! Check out all the other language
features in the [OpenSCAD
Manual](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual).
2012-05-08 02:00:31 +04:00
# Documentation
2012-05-08 02:00:31 +04:00
Have a look at the OpenSCAD Homepage (http://openscad.org/) for documentation.
## Building OpenSCAD
2012-05-08 05:21:01 +04:00
To build OpenSCAD from source, follow the instructions for the
platform applicable to you below.
2012-05-08 02:00:31 +04:00
### Prerequisites
To build OpenSCAD, you need some libraries and tools. The version
numbers in brackets specify the versions which have been used for
2012-05-08 02:00:31 +04:00
development. Other versions may or may not work as well.
If you're using a newer version of Ubuntu, you can install these
2012-12-21 02:12:49 +04:00
libraries from aptitude. If you're using Mac, or an older Linux/BSD, there
are build scripts that download and compile the libraries from source.
Follow the instructions for the platform you're compiling on below.
2015-01-21 09:09:09 +03:00
* [Qt4 (4.4 - 5.4)](http://www.qt.nokia.com/)
* [QScintilla2 (2.7 - 2.8)](http://www.riverbankcomputing.co.uk/software/qscintilla/)
* [CGAL (3.6 - 4.5)](http://www.cgal.org/)
2013-03-18 02:30:29 +04:00
* [GMP (5.x)](http://www.gmplib.org/)
2012-05-08 02:00:31 +04:00
* [MPFR (3.x)](http://www.mpfr.org/)
2015-01-21 09:09:09 +03:00
* [cmake (2.8 - 3.0, required by CGAL and the test framework)](http://www.cmake.org/)
* [boost (1.35 - 1.57)](http://www.boost.org/)
* [OpenCSG (1.3.2 ->)](http://www.opencsg.org/)
* [GLEW (1.5.4 ->)](http://glew.sourceforge.net/)
* [Eigen (3.x)](http://eigen.tuxfamily.org/)
* [glib2 (2.x)](https://developer.gnome.org/glib/)
2015-01-21 09:09:09 +03:00
* [fontconfig (2.10 -> )](http://fontconfig.org/)
* [freetype2 (2.4 -> )](http://freetype.org/)
* [harfbuzz (0.9.19 -> )](http://harfbuzz.org/)
* [Bison (2.4 -> )](http://www.gnu.org/software/bison/)
* [Flex (2.5.35 -> )](http://flex.sourceforge.net/)
* [pkg-config (0.26 -> )](http://www.freedesktop.org/wiki/Software/pkg-config/)
### Getting the source code
Install git (http://git-scm.com/) onto your system. Then run a clone:
git clone git://github.com/openscad/openscad.git
This will download the latest sources into a directory named 'openscad'.
To pull the MCAD library (http://reprap.org/wiki/MCAD), do the following:
cd openscad
2013-04-19 06:42:09 +04:00
git submodule update --init
2012-05-08 05:21:01 +04:00
### Building for Mac OS X
2012-05-08 02:00:31 +04:00
2013-03-22 17:48:30 +04:00
Prerequisites:
2015-01-21 09:04:51 +03:00
* XCode, including XCode command-line tools.
2013-03-22 17:48:30 +04:00
2015-01-21 09:04:51 +03:00
Install Dependencies:
2012-05-08 02:00:31 +04:00
2015-01-21 09:04:51 +03:00
Run the script that sets up the environment variables:
```source setenv_mac-qt5.sh```
2012-05-08 02:00:31 +04:00
2015-01-21 09:04:51 +03:00
Then run the script to compile all the dependencies:
```./scripts/macosx-build-dependencies.sh```
2012-05-08 02:00:31 +04:00
2015-01-21 09:04:51 +03:00
After building dependencies, follow the instructions in the *Compilation* section.
For the adventurous, it might be possible to build OpenSCAD using _MacPorts_ or _Homebrew_. The main challenge is that both these systems have partially broken libraries, but that tends to change from time to time.
1. **MacPorts** (assumes [MacPorts](http://macports.org) is already installed)
NB! MacPorts currently doesn't support Qt5 very well, so using Qt4
is the only working option at the moment. However, MacPorts' Qt4
has a broken ```moc``` command, causing OpenSCAD compilation to
break. This may be fixed in MacPorts by the time you read this.
```sudo port install opencsg qscintilla boost cgal pkgconfig eigen3 harfbuzz fontconfig```
1. **Homebrew** (assumes [Homebrew](http://brew.sh)) is already installed)
NB! Homebrew's ```qscintilla2``` component doesn't support Qt5, so using Qt4 is currently necessary.
However, Homebrew's Qt4 has a broken ```moc``` command, causing OpenSCAD compilation to
break. This may be fixed in Homebrew by the time you read this.
NB! Homebrew's ```harfbuzz``` package requires X11, so you may have to install an X11 server.
NB! Homebrew doesnt have an OpenCSG package
```brew install cgal qscintilla2 eigen harfbuzz```
2012-05-08 02:00:31 +04:00
### Building for Linux/BSD
2012-12-23 04:00:48 +04:00
First, make sure that you have git installed (often packaged as 'git-core'
or 'scmgit'). Once you've cloned this git repository, download and install
the dependency packages listed above using your system's package
manager. A convenience script is provided that can help with this
process on some systems:
sudo ./scripts/uni-get-dependencies.sh
After installing dependencies, check their versions. You can run this
script to help you:
./scripts/check-dependencies.sh
2012-05-08 02:00:31 +04:00
Take care that you don't have old local copies anywhere (/usr/local/).
2012-12-20 21:03:04 +04:00
If all dependencies are present and of a high enough version, skip ahead
to the Compilation instructions.
### Building for Linux/BSD on systems with older or missing dependencies
If some of your system dependency libraries are missing or old, then you
can download and build newer versions into $HOME/openscad_deps by
following this process. First, run the script that sets up the
environment variables.
2012-12-20 21:03:04 +04:00
source ./scripts/setenv-unibuild.sh
Then run the script to compile all the prerequisite libraries above:
2012-12-20 21:03:04 +04:00
./scripts/uni-build-dependencies.sh
Note that huge dependencies like gcc, qt, or glib2 are not included
here, only the smaller ones (boost, CGAL, opencsg, etc). After the
build, again check dependencies.
2012-12-20 21:03:04 +04:00
./scripts/check-dependencies.sh
After that, follow the Compilation instructions below.
2012-05-08 02:00:31 +04:00
### Building for Windows
OpenSCAD for Windows is usually cross-compiled from Linux. If you wish to
attempt an MSVC build on Windows, please see this site:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Windows
2012-05-08 02:00:31 +04:00
To cross-build, first make sure that you have development tools
installed to get GCC. Then after you've cloned this git repository,
2013-05-19 00:40:01 +04:00
start a new clean bash shell and run the script that sets up the environment
variables.
2013-05-19 00:40:01 +04:00
source ./scripts/setenv-mingw-xbuild.sh 32
Then run the script to download & compile all the prerequisite libraries above:
2013-05-19 00:40:01 +04:00
./scripts/mingw-x-build-dependencies.sh 32
Note that this process can take several hours, as it uses the
http://mxe.cc system to cross-build many libraries. After it is
complete, build OpenSCAD and package it to an installer:
2012-08-02 08:14:34 +04:00
./scripts/release-common.sh mingw32
2013-01-27 00:19:42 +04:00
If you wish you can only build the openscad.exe binary:
cd mingw32
qmake ../openscad.pro CONFIG+=mingw-cross-env
2013-01-27 00:19:42 +04:00
make
2013-05-19 00:40:01 +04:00
For a 64-bit Windows cross-build, replace 32 with 64 in the above instructions.
2012-05-08 02:00:31 +04:00
### Compilation
2015-01-21 09:04:51 +03:00
First, run 'qmake openscad.pro' from Qt4 to generate a Makefile.
On some systems, depending on which version(s) of Qt you have installed, you may need to specify which version you want to use, e.g. by running 'qmake4', 'qmake-qt4' or something alike.
Then run make. Finally you might run 'make install' as root or simply copy the
'openscad' binary (OpenSCAD.app on Mac OS X) to the bin directory of your choice.
2012-05-08 05:21:01 +04:00
If you had problems compiling from source, raise a new issue in the
[issue tracker on the github page](https://github.com/openscad/openscad/issues).
This site and it's subpages can also be helpful:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_OpenSCAD_from_Sources