OpenSCAD User Manual/The OpenSCAD User Interface

From Wikibooks, open books for an open world
Jump to: navigation, search

User Interface[edit]

Main Window of OpenSCAD with a small script generating the OpenSCAD-Logo.

The user interface of OpenSCAD has three parts

  • The viewing area
  • The console window
  • The text editor

Viewing area[edit]

Preview and rendering output goes into the viewing area. Using the Show Axes menu entry an indicator for the coordinate axes can be enabled.

Console window[edit]

Status information, warnings and errors are displayed in the console window.

Text editor[edit]

The built-in text editor provides basic editing features like text search & replace and also supports syntax highlighting. There are predefined color schemes which can be selected in the Preferences dialog.

OpenSCAD Find Dialog
OpenSCAD Replace Dialog
OpenSCAD Editor with Find / Replace functionality.


View navigation[edit]

The viewing area is navigated primarily using the mouse:

  • Dragging with the left mouse button rotates the view along the axes of the viewing area. It preserves the vertical axis' direction.
  • Dragging with the left mouse button when the shift key is pressed rotates the view along the vertical axis and the axis pointing towards the user.
  • Dragging with the right mouse button moves the viewing area.
  • For zooming, there are four ways:
    • using the scroll wheel
    • dragging with the middle mouse button
    • dragging with the right or middle mouse button and the shift key pressed
    • the keys + and -

Rotation can be reset using the shortcut Ctrl+0. Movement can be reset using the shortcut Ctrl+P.

View setup[edit]

The viewing area can be configured to use different rendering methods and other options using the View menu. Most of the options described here are available using shortcuts as well.

Render modes[edit]

OpenCSG (F9)[edit]

This method produces instantaneous results, but has low frame rates when working with highly nonconvex objects.

Note that selecting the OpenCSG mode using F9 will switch to the last generated OpenCSG view, but will not re-evaluate the source code. You may want to use the Compile function (F5, found in the Design menu) to re-evaluate the source code, build the OpenCSG objects and then switch to OpenCSG view.

Implementation Details[edit]

In OpenCSG mode, the OpenCSG library is used for generating the visible model. This library uses advanced OpenGL features (2.0) like the Z buffer and does not require an explicit description of the resulting mesh – instead, it tracks how objects are to be combined. For example, when rendering a spherical dent in a cube, it will first render the cube on the graphics card and then render the sphere, but instead of using the Z buffer to hide the parts of the sphere that are covered by the cube, it will render only those parts of the sphere, visually resulting in a cube with a spherical dent.

CGAL (Surfaces and Grid, F10 and F11)[edit]

This method might need some time when first used with a new program, but will then have higher framerates.

As before with OpenCSG, F10 and F11 only enable CGAL display mode and don't update the underlying objects; for that, use the Compile and Render function (F6, found in the Design menu).

To combine the benefits of those two display methods, you can selectively wrap parts of your program in a render function and force them to be baken into a mesh even with OpenCSG mode enabled.

Implementation Details[edit]

The acronym CGAL refers to The Open Source Computational Geometry Algorithms Library.

In CGAL mode, the CGAL library is used to compute the mesh of the root object, which is then displayed using simple OpenGL.

View options[edit]

Show Edges (Ctrl+1)[edit]

The difference between the CGAL and OpenCSG approaches can be seen at edges created by boolean operations.

If Show Edges is enabled, both OpenCSG and CGAL mode will render edges as well as faces, CGAL will even show vertices. In CGAL grid mode, this option has no effect.

Enabling this option shows the difference between OpenCSG and CGAL quite clearly: While in CGAL mode you see an edge drawn everywhere it "belongs", OpenCSG will not show edges resulting from boolean operations – this is because they were never explicitly calculated but are just where one object's Z clipping begins or ends.

Show Axes (Ctrl+2)[edit]

If Show Axes is enabled, the origin of the global coordinate system will be indicated by an orthogonal axes indicator. Additionally, a smaller axes indicator with axes names will be shown in the lower left corner of the viewing area. The smaller axes indicator is marked x, y, z and coloured red, green, blue respectively.

Show Crosshairs (Ctrl+3)[edit]

If Show Crosshairs is enabled, the center of the viewport will be indicated by four lines pointing in the room diagonal directions of the global coordinate system. This is useful when aligning the viewing area to a particular point in the model to keep it centered on screen during rotation.

Animation[edit]

The Animate option adds an animation bar to the lower edge of the screen. As soon as FPS and Steps are set (reasonable values to begin with are 10 and 100, respectively), the current Time is incremented by 1/Steps, FPS times per second, until it reaches 1, when it wraps back to 0.

Every time Time is changed, the program is re-evaluated with the variable $t set to the current time. Read more about how $t is used in section Other_Language_Features

View alignment[edit]

The menu items Top, Bottom, …, Diagonal and Center (Ctrl+4, Ctrl+5, …, Ctrl+0, Ctrl+P) align the view to the global coordinate system.

Top, Bottom, Left, Right, Front and Back align it in parallel to the axes, the Diagonal option aligns it diagonally as it is aligned when OpenSCAD starts.

The Center option will put the coordinate center in the middle of the screen (but not rotate the view).

By default, the view is in Perspective mode, meaning that distances far away from the viewer will look shorter, as it is common with eyes or cameras. When the view mode is changed to Orthogonal, visible distances will not depend on the camera distance (the view will simulate a camera in infinite distance with infinite focal length). This is especially useful in combination with the Top etc. options described above, as this will result in a 2D image similar to what one would see in an engineering drawing.