Search code examples
debugginghighlightopenscad

Difference in behavior in OpenSCAD between % and #


Using OpenSCAD 2019.05 on Mac OS 10.15.7,

difference() {
  cube(size = [14, 24, 17], center = false);
  % cube(size = [10, 20, 17], center = false);
}

fails (sometimes with the familiar "No geometry" error, sometimes with a cube with no subtraction).

However, with only the substition of # for %, the expected behavior is produced. Am I misunderstanding the semantics of # and %?

(As you'd expect, I didn't write the code this way, I took CSG output from my original program and boiled it down to this example.)


Solution

  • I used to get confused by them too. % allows you to put things in the F5 preview of the model that will not show up in the actual render with F6. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Modifier_Characters#Background_Modifier "Ignore this subtree for the normal rendering process and draw it in transparent gray (all transformations are still applied to the nodes in this tree)."

    So, the line with % is being ignored when you render it and it should result in the first cube being rendered unmodified.