Difficulty:: Medium.
Next Tutorial:

Rotating and Extruding a dxf file

In the previous tutorial we showed how to include a dxf file to extrude it on linear way. It's useful when the shape we want is too complex. Here, we're going to see another way to extrude a 2D picture: around z axis. For that, we use the rotateExtrudeFromDXF function, which asks like parameters the file's name, convexity and faces number.

Component toroid(Component::rotateExtrudeFromDXF("circunference.dxf",5));

We declare a component called toroid, in which we import the circunference file with 10 of convexity and 100 faces number (by default).

After that, we move the component by centering it.

toroid.translate(0,0,-135);

The toroid component is translated 135 mm along z axis.

If we want to generate the OpenSCAD code for this component, we simply run:

IndentWriter writer; 
 
writer << toroid;
 
std::cout << writer;
//or
writer.dump(std::cout);

This will send to the standard output the following

translate(v=[0.000, 0.000, -135.000]) {
  rotate_extrude(file="circunference.dxf", convexity=10, $fn=100);
} // End translate

The full code would be:

IndentWriter writer;
 
// Output file which contains the OpenSCAD code.
ofstream os("dxf.scad");
 
// Import the circunference file, and extrude it around z axis with 5 of convexity.
Component toroid(Component::rotateExtrudeFromDXF("circunference.dxf",5));
 
// Translate the created toroid along z axis.
toroid.translate(0,0,-135);
 
// Generate the OpenSCAD code.
writer << toroid;
os << writer;
os.close();

Next Tutorial:

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