Category Archives: 3D modelling

Using AngelScript CSG

Download AngelScript CSG version V2.0-02, with IDE included
Windows 64bit here.
Linux (K)ubuntu 15.10 64bit here.

AngelScript CSG is a work in progress, see the previous articles on this blog. Today's article is providing practical information on installing and using the software.

Windows 64bit

The AngelScript CSG setup package will install the script compiler as_csg.exe and the editor/IDE as_ide.exe. ​​ However, before installing the setup package, please make sure to install the Visual C++ Redistributable Packages for Visual Studio 2013, issued by Microsoft. You will also need a recent version of OpenSCAD installed on your system.

Linux (K)ubuntu 15.10 64bit

The angelscript_csg.tar.gz contains the binaries for AngelScript CSG script compiler as_csg and the editor/IDE as_ide. Extract the contents to a suitable folder ~/angelscript_csg is recommended. ​​ You will also need a recent version of OpenSCAD installed on your system. If you extracted to folder ~/angelscript_csg, add this to bottom of your ~.bashrc file:

 export PATH=$PATH:~/angelscript_csg

export LD_LIBRARY_PATH==LD_LIBRARY_PATH=:~/angelscript_csg

A small taste of the AngelScript language

If you are familiar with C, C++ or similar languages the learning curve will be short and painless. AngelScript is similar in most respects. A relatively complete description of the general language is found here, but as a short primer here are a few key points to know

  • The language is strongly typed, variables must be declared with a type as in C or C++

  • Line comment lines are preceded by double slash //

  • Comment blocks begin with /* ​​ and end with */

  • There are two forms of objects, reference types and value types.

The value types are like the primitives

 int i  ​​​​ ​​ = 0;  ​​ ​​ ​​ ​​ ​​ ​​​​ // an integer value type

doble pi = 3.13159; ​​ // a floating point value type

The reference types uses object handles. Object handles are used to hold references to other objects. When calling methods or accessing properties on a variable that is an object handle you will be accessing the actual object that the handle references, just as if it was an alias.

 double radius = 3;

 sphere@ s ​​  = sphere(radius);  ​​ ​​ ​​ ​​ ​​​​ // handle to a sphere

cylinder@ s = cylinder(10,radius); ​​ // handle to a cylinder

cylinder@ s2 = @s;    // 2nd handle to same cylinder

  • Functions are defined as in C/C++, returning value types or reference types

double sum(double a, double b)


 ​​ ​​ ​​​​    ​​​​ return a+b;


solid@ sum(cylinder@ c, sphere@ s)
   ​​​​ return union3d(c,s);

  • Arrays may be defined for value types or reference types

int[] iarr = {0,1,2,3,4,5};

solid@[] sarr = { cylinder(10,3), sphere(3) };


// build a growing array of spheres with increasing radius

sphere@[] spheres;

for(int i=0; i<10; i++) spheres.push_back(sphere(i));


// report the size of the array to terminal (answer will be 10)

cout << spheres.size() << endl();

The above is just a small taste of the language. If it catches your interest, you may want to look at the the full language description for more details. Remember also that withing the AngelScript CSG IDE you can use Help → View Documentation to find more specifics on how to construct the various CSG objects that are not described in the general AngelScript language description.

Another topic is transformations, but we leave that for another day.

AngelScript CSG IDE

Download AngelScript CSG version V2.0-02, with IDE included
Windows 64bit here.
Linux (K)ubuntu 15.10 64bit here.

This is an update to previous articles part 1, ​​ part 2 and part3 on AngelScript CSG. It is a work in progress, the goal is to establish a powerful modelling system enabling Constructive Solid Geometry (CSG) modelling based on the AngelScript scripting language.
Today's update is to introduce phase 2 of this project – the ​​ AngelScript CSG IDE. The first phase focused on the implementation of the scripting compiler, that is the command line program that interprets AngelScript .as files and turn them into OpenSCAD .csg files. The addition in phase 2 is an editor/IDE that allows easy editing of multiple AngelScript files with syntax highlighting, brace matching etc. It also runs the script compiler and highlights any errors in an easy manner. For model visualisation, launch OpenSCAD from within the IDE. If the .as file is changed/recompiled then OpenSCAD can be made to refresh automatically.

Below is a quick introduction to how it works. The user (you) writes AngelScript CSG code in the IDE and compiles it using either the Build menu, the green arrow in the toolbar or simply pressing F5 on the keyboard. This will save the *.as file to the disk and run the command line compiler, producing an OpenSCAD *.csg file. If you have not already done so you can launch OpenSCAD from the Build menu (or press F6) to view the 3d model.

If you set OpenSCAD to automatically reload modified files, you can simply continue editing the *.as file and press F5 and it will be updated automatically in OpenSCAD when required.

Angelscript CSG and OpenSCAD working together.

Below is an illustration of what happens if you make a coding mistake, you get an error message in red in the console window at bottom, and a red marker indicates the line of the first error. In the exampe, the user wrote 'doublex' by mistake instead of 'double'.

Highlighting coding errors (Windows)

The program also runs on Linux Kubuntu 15.10 64 bit. Below is the Find & Replace feature used under linux to fix a similar programming error.

Fixing coding errors (Linux)

All for today :-) Please give it a try and leave your comments below.


AngelScript CSG – part 3

Download AngelScript CSG version V2.0-02, with IDE included
Windows 64bit here.
Linux (K)ubuntu 15.10 64bit here.

This is an update to previous articles part 1 and part 2 on AngelScript CSG, which is using AngelScript as a language for Constructive Solid geometry (CSG).

Today's update is to describe the latest couple of changes. One may now create polyhedrons from image files and from OpenSCAD style text files. To support images a new command “image2d” has been introduced, supporting image files of type PNG, JPG, GIF, XPM and more. It is also possible to resample an imported image before using it to create a 3d model.

Ektepar (Carsten J. Arnholm) - Copyright ©