Difficulty:: Medium.
Next Tutorial: The Dummy Part

Importing OpenSCAD Code

A very important feature of the OOML is the possibility to reuse the tons of existing OpenSCAD Code. In this tutorial we are using a Batmat Symbol designed with OpenSCAD and uploaded to Thingivere.com.

We must first of all download the OpenSCAD code of the thing Batman Symbol (by Seynls. We place the OpenSCAD code in the same directory that our OOML application will be:

For Importing Openscad code we use the Imported Class provided by OOML, and call the import_from_file function. The created Object is a “full” ooml object that can be translated, rotated, scaled, added to other objects, etc.

A code example would be:

#include <components/Cube.h>
#include <components/Cylinder.h>
#include <core/IndentWriter.h>
 
#include <iostream>
#include <fstream>
 
using namespace std;
 
int main(int argc, char **argv)
{
	 IndentWriter writer;
 
         // Output file which contains the OpenSCAD code.
         ofstream os("my_batman.scad");
 
         // Load the OpenSCAD code.
         Component batman(Component::loadFromFilename("BATMAN.scad"));
 
         // Scale  batman part.
         batman.scale(5,5,20);
 
         // Generate the OpenSCAD code.
         writer << batman;
	 os << writer;
	 os.close();
 
	return 0;
}

This file creates a file called my_batman.scad, that opened with OpenSCAD renders the following object (an scaled version of the original).

Next Tutorial: The Dummy Part

Recent changes RSS feed Creative Commons License Donate Minima Template by Wikidesign Driven by DokuWiki