Talk:OpenSCAD User Manual/Using OpenSCAD in a command line environment

Is there a way to generate the graphical window from the CL? I want to use the CL just because I want to use a real text editor to create the file (arrow keys do *not cut it), but I'd still like to see the OpenGL, interactive graphics when I "compile" it.

i'm not sure why the .SECONDARY line is needed, please post ideas here --chrysn (talk) 23:11, 22 May 2010 (UTC)
 * Make by default deletes intermediary files under certain conditions, see . The .PRECIOUS target is also used for this purpose, and the linked page is not really clear which one is more appropriate. —Preceding unsigned comment added by 67.232.185.87 (discuss • contribs) 04:24, 23 May 2010
 * using .PRECIOUS would be inappropriate here as it might leave partially completed files (as of reading your link, i should probably add the .DELETE_ON_ERROR target as well). the question is not what .SECONDARY does, but why, when the intermediate files are deleted, make would re-bulid the whole project on subsequent runs *although not a bit was changed*. --chrysn (talk) 22:44, 26 May 2010 (UTC)
 * For each .stl make will check if the sources are newer. Since the .scad files are regenerated, they are newer than the .stl files. Hence make will rebuild them.

Could someone include a real world example that shows/explains why 'Automatic targets' is useful? Mimarx (discuss • contribs) 02:29, 23 February 2013 (UTC)


 * Just started using this myself. Project is a 3d printed SBC (ex:raspberry Pi) with multiple parts created by multiple modules. Some modules need exported to .stl, some don't. So for example there is a bottom, top, front, side, etc. The make script finds those bottom, top, front, side modules and creates an .stl for each so I don't have to manually repear the process of render, export, type bottom, render, export, type top, render export, type front, etc. I also have one part that need flipped over to print so a conditional rotate x 180 is in there so it flips the .stl when its creating it. EugeneNine (discuss • contribs) 16:34, 7 November 2021 (UTC)

STL to an Image Format
I need help to know the syntax to use an OpenSCAD fast command from Windows Command Line Shell to convert a 3D .STL model to an image format (.BMP, .PNG, .JPG or .PDF). ( For example: command model.stl model.png ).

Can't get makefile example working
I'm not understanding the exact match it's looking for with the sed command. Is there an example scad file to explain?

Copy and paste the example into a file called makefile In the same directory create a new OpenSCAD file called base.scad as in the example. Inside that create a module with the comment // make me like this:

module test{ // make me       cube([1,1,1]); };

The line TARGETS=$(shell sed '/^module [a-z0-9_-]*.*make..\?me.*$$/!d;s/module //;s/.*/.stl/' base.scad) finds the name of each module that has a //make me in the file called base.cad then the rest of the make file loops though them. Now you can replace base.scad (in two places in the make file) with the name of your .scad file.

Module names and case sensitivity
might I suggest changing the sed line in the Automatic_targets example from: TARGETS=$(shell sed '/^module [a-z0-9_-]*.*make..\?me.*$$/!d;s/module //;s/.*/.stl/' base.scad)

to:

TARGETS=$(shell sed '/^module [a-zA-Z0-9_-]*.*make..\?me.*$$/!d;s/module //;s/.*/.stl/' base.scad)

It took me a minute to notice why one of my modules with a capitalized name wasn't building

Less complex Makefile
I found the existing Makefile to be a bit hard to understand and this to be a bit less so. I'm not entirely sure what the `-m make` is for though. I think this version should work with both GNU make and BSD make.

SCAD=base.scad SUFFIX = .stl # match "module foobar { // `make` me" TARGETS != sed -n 's/^module *\([A-Za-z0-9_-]*\) *.*make.* me.*$$/\1$(SUFFIX)/p' $(SCAD) all: ${TARGETS} .SUFFIXES: ${SUFFIX} ${TARGETS}: $(SCAD) echo 'use <$(SCAD)>;\n$*;' | openscad -m make -o $@ - 75.164.72.13 (discuss) 01:27, 12 April 2023 (UTC)