[OpenSCAD] Questions from a new user
Giles Bathgate
gilesbathgate at gmail.com
Thu Mar 11 09:34:03 CET 2010
On Wed, 2010-03-10 at 22:02 -0500, Jeff Newbern wrote:
> Hello,
>
> I've just picked up OpenSCAD and I'm enjoying exploring the tool. I
> can see that it has great potential, but I'm being slowed down by the
> lack of a thorough reference for the scripting language. I have a few
> questions that I hope experienced users on this list will be able to
> answer easily.
Have you read http://en.wikibooks.org/wiki/OpenSCAD_User_Manual ?
> First, it seems that the syntax for function declarations is:
>
> function <name>([<formal arguments>]) = <expression> ;
not really the syntax is
function <name>(<arguments>) = <expression> ;
e.g. r_from_dia(d) = d/2;
> Is there a ternary operator (something like <cond> ? <true_expr> :
> <false_expr>) so that function return values can be conditional?
yes there is an undocumented ternary operator the syntax is as you say
the only thing I have found is sometimes you need extra brackets
e.g. (a==1) ? "True" : "False"
or (a>7) ? (d/2) : (d/3);
> Alternatively, is there a function syntax similar to:
>
> function <name>([<formal arguments>]) {
> <body>
> }
>
> where the function body can contain an if-else tree with return
> <expression> statements?
I don't think there is yet.
> The other thing which seems like it would be useful is to be able to
> query the bounding volume for an object. This would let me write
> functions to automatically align, center, etc. collections of objects.
>
> Also, if you have any general tips for a new user (coding style,
> proper composition, best practices, etc.) I'm sure I would benefit
> from your experience.
>
> Thank you,
> Jeff
>
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
More information about the Openscad
mailing list