Prev: Tutorials
Build your own customizable objects with Sculpteo¶
Presented in London for the 3D Print Show 2012.
This tutorial presents our customization tools and environment, from basic interactive tools to advanced scripting. For more information on the scripting features presented here, see Using XML to describe designs and Using JavaScript for scripting designs.
Interactive Tools Example¶
Our company logo, that we are going to customize with interactive tools:
Template Design Example¶
A prepared design template, end-users sees only a single customization option to modify the text that was added to the original design. Other options, such as font, size, or color, were locked by and may not be modified by the user.
OpenSCAD Examples¶
A plain OpenSCAD file, directly imported on our website:
OpenSCAD File Download
module example001() { function r_from_dia(d) = d / 2; module rotcy(rot, r, h) { rotate(90, rot) cylinder(r = r, h = h, center = true); } difference() { sphere(r = r_from_dia(size)); rotcy([0, 0, 0], cy_r, cy_h); rotcy([1, 0, 0], cy_r, cy_h); rotcy([0, 1, 0], cy_r, cy_h); } size = 50; hole = 25; cy_r = r_from_dia(hole); cy_h = r_from_dia(size * 3); } example001();
The same file, slightly modified by adding comments and variables to make some parameters customizable by the end-user:
OpenSCAD Customizable File Download
// angle X AX=90; // angle Y AY=90; // [45:90] module example001(anglex,angley) { function r_from_dia(d) = d / 2; module rotcy(rot, r, h, angle) { rotate(angle, rot) cylinder(r = r, h = h, center = true); } difference() { sphere(r = r_from_dia(size)); rotcy([0, 0, 0], cy_r, cy_h, 90); rotcy([1, 0, 0], cy_r, cy_h, anglex); rotcy([0, 1, 0], cy_r, cy_h, angley); } size = 50; hole = 25; cy_r = r_from_dia(hole); cy_h = r_from_dia(size * 3); } example001(anglex=AX,angley=AY);
XML Example¶
Our logo, uploaded with a XML companion file describing it and how it may be customized. Here the customization option is to replace the color of the ball inside the logo:
ZIP archive with the logo 3DS file and the XML file Download
XML Companion File
<?xml version="1.0" encoding="UTF-8"?> <sculpteo> <design configurable="1"> <name>Logo</name> <description>This is our company logo, choose the color of the ball.</description> <model src="logo.3ds"/> <operation type="replacecolor"> <color rgb="#ff0000" locked="0"/> <material id="2" locked="1"/> </operation> </design> </sculpteo>
Javascript Examples¶
Sandbox designs with modifiable scripts, useful for easily testing scripts by replacing or editing the existing ones:
A simple script, creating a sphere with three drilled holes:
-
var sphere = new Sphere(); var cylinder = new Cylinder(0.5, 2); sphere.color(0, 0, 1); cylinder.color(0, 1, 0); sphere.difference(cylinder); sphere.difference(cylinder.rotate(90, 0, 0)); sphere.difference(cylinder.rotate(0, 0, 90)); append(sphere);
A more complex script, creating a cylinder with alternating smooth or rough side. The use of the built-in Javascript Math.random function is illustrated, as well as the use of a parametric function to build a primitive:
-
var NU = 200; var NV = 200; var amplitude = 0.01; var frequency = 10; function F(u, v) { var cu = Math.cos((u * 2 * Math.PI) / NU); var su = Math.sin((u * 2 * Math.PI) / NU); var r = 1.0 - amplitude + amplitude * Math.random(); if (parseInt(u / (NU / frequency)) % 2) r = 1; var x = su * r; var y = cu * r; var z = 2.0 * (v / NV); return [x, y, z]; } var parametric_primitive = new ParametricSurface(NU, NV, F); append(parametric_primitive);
Full Example¶
A full example of a scripted customizable design. The script is included inline in the XML file:
-
<?xml version="1.0" encoding="UTF-8"?> <sculpteo> <design configurable="1"> <name>Drilled Sphere</name> <description>Customizable drilled sphere.</description> <operation type="script"> <parameter type="slider" value="0.3" min="0.1" max="0.5"> <description>Drilling radius</description> <bind value="radius" /> </parameter> <script locked="1"> /* <![CDATA[ */ var sphere = new Sphere(); var cylinder = new Cylinder(radius, 2); sphere.color(0,0,1); cylinder.color(0,1,0); sphere.difference(cylinder); sphere.difference(cylinder.rotate(90,0,0)); sphere.difference(cylinder.rotate(0,0,90)); append(sphere); /* ]]> */ </script> </operation> </design> </sculpteo>
More Examples¶
A fractal tree made by recursively calling a function creating its branches:
Adding randomness to the previous example creates more interesting trees:
A customizable lucky coin, illustrating the design selection parameter, the font selection parameter, drawing text along a curved arc, CSG operations, and more:
The “flakeball”, a customizable design for your Christmas tree. Illustrates the use of the generic selection parameter, and the use of functions to better organize the code:
» webapi documentation » Tutorials » Build your own customizable objects with Sculpteo
Last update: 1970-01-01 01:00 (CET)