openscad/openscad — pull request #457 by steelman (2013-08-15 22:21:51+00:00)
Title: Introduce '_current_module' and '_parent_module' variables

Add two built-in variables that provide access to the names
of the current and the previously instantiated modules.

Having these variables simplifies generation of BOMs and assembly
graphs (e.g. with GraphViz).

For example:

```
module foo() {
echo(str("foo:", _parent_module, ":", _current_module));
bar();
echo(str("foo:", "still in", " ", _current_module));
baz();
echo(str("foo:", "finishing", " ", _current_module));
}

module bar() { echo(str("bar:", _parent_module, ":", _current_module)); baz(); }

module baz() { echo(str("baz:", _parent_module, ":", _current_module)); }

translate ([0,0,0]) foo();
```

gives

```
ECHO: "foo:undef:foo"
ECHO: "bar:foo:bar"
ECHO: "baz:bar:baz"
ECHO: "foo:still in foo"
ECHO: "baz:foo:baz"
ECHO: "foo:finishing foo"
```
With a single warning about undefined '_parent_module' variable in the top-level foo() module.