Skip to main content
Post Made Community Wiki by Dennis
Length 20
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39

Length 20:

Let's do some animation!

$vpr= [45,0,$t*360];

$vpr is a special variable in OpenSCAD. It contains the rotation of the viewport ($vpt and $vpd contain the translation and distance, respectively). If you assign them a new value, the viewport changes to that value.

As stated earlier, $t contains a value between 0 and 1.

To start with animation, click View > Animate. That will bring up a bar like this:

Bar

Time will automatically change when you configure the other two values. This becomes the value of $t.

Steps means the amount of steps that $t will go through between 0 and 1.

FPS is the amount of steps OpenSCAD will go through every second.

If "Dump Pictures" is selected, as OpenSCAD goes through the animation, it will save the pictures sequentially.

With the above code, 30 steps, and 10 FPS, I get this exciting animation:

Super exciting

Of course, you can use $t in other places as necessary.

Length 20:

Let's do some animation!

$vpr= [45,0,$t*360];

$vpr is a special variable in OpenSCAD. It contains the rotation of the viewport ($vpt and $vpd contain the translation and distance, respectively). If you assign them a new value, the viewport changes to that value.

As stated earlier, $t contains a value between 0 and 1.

To start with animation, click View > Animate. That will bring up a bar like this:

Bar

Time will automatically change when you configure the other two values. This becomes the value of $t.

Steps means the amount of steps that $t will go through between 0 and 1.

FPS is the amount of steps OpenSCAD will go through every second.

If "Dump Pictures" is selected, as OpenSCAD goes through the animation, it will save the pictures sequentially.

With the above code, 30 steps, and 10 FPS, I get this exciting animation:

Super exciting

Of course, you can use $t in other places as necessary.

Length 19
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39

Length 19:

import("model.stl");

(Note that STL is a file format for 3D models. It contains a triangular mesh of all of the surfaces in a model.)

If I save the hilbert cube model from here as model.stl in the same folder as the .scad file, OpenSCAD allows you to use it as a component of the model (e.g. you can perform CSG operations on the model).

Hilbert cube

Length 19:

import("model.stl");

(Note that STL is a file format for 3D models. It contains a triangular mesh of all of the surfaces in a model.)

If I save the hilbert cube model from here as model.stl in the same folder as the .scad file, OpenSCAD allows you to use it as a component of the model (e.g. you can perform CSG operations on the model).

Hilbert cube

Length 18
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39

Length 18:

While you can't set arrays from inside a for loop (the variable inside the for loop shadows the variable in the wider scope), OpenSCAD compensates by adding list comprehensions.

[for(i=[1:10])i*2]

This list comprehension iterates i from 1 through 10, and for each value of i, the result is 2i. This expression results in the array [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]. Note that this array could have been produced with [2:2:20].

Length 18:

While you can't set arrays from inside a for loop (the variable inside the for loop shadows the variable in the wider scope), OpenSCAD compensates by adding list comprehensions.

[for(i=[1:10])i*2]

This list comprehension iterates i from 1 through 10, and for each value of i, the result is 2i. This expression results in the array [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]. Note that this array could have been produced with [2:2:20].

Length 17
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 16
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 15
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 14
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 13 + some minor edits
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 12
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 11
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 10
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 9
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 8
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 7
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 6
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 5
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 4
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 3
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Length 2
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
1 character
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading
Source Link
Daniel M.
  • 3.9k
  • 2
  • 26
  • 39
Loading