[OpenSCAD] eval( ) ???

runsun runsun at gmail.com
Tue May 19 00:12:44 EDT 2015

That's an interesting approach. It'd be great to see it work in the near
future. Thoughts:

1) There will be some way to add new component or remove existing one, right

2) One thing that I'd like to see (for any new design in openscad) is for
shapes to bear coordinate info. Unfortunately this new design doesn't have
it. There's a "translate(...)" from which we know where it is, but that's by
reading the code. 

In my coding all the shapes I design have the coordinates as the first
argument. The openscad default usage ( i.e., everything starts from [0,0,0]
) is just a special case. With that, I can build my shape starting on any
coordiate. That saves a lot of brain power trying to figure out how to
rotate and move a new part to fit the existing one. 

doug.moen wrote
> Runsun said:
>> Also would be great if, other than *data.a*, we can do *x=data["a"]*,
>> *x=data("a")* (in case it needs to contain space) or even *x=data(a)*.
> I would vote for data["a"] or data.("a")
>> One more thing, variable name like 3a, 4b are allowed in openscad. Will
>> data.3a also be allowed ?
> Of course.
>> And, on top of that, we also need:
>>    keys(data) ==> ["a","b"]
>>    values(data) ==> [10,20]
>> or data.keys, data.values, such that they can be iterated over.
> I'll grant the need for keys(data). But values is just
>    [for (k=keys(data)) data[k]]
> and I don't know that it would be needed often enough to justify as a
> builtin.
> This brings up: if we do *[ for(x=data) ...]*, what would x stands for.
> OpenSCAD scripts are the model for what objects are. An object is a set of
> named fields, and a sequence of shapes. Consider:
> lollypop = {
>   radius = 3;
>   diameter = 1;
>   height = 10;
>   translate([0,0,height]) sphere(r=radius);
>   cylinder(d=diameter,h=height);
> };
> You can use 'lollypop' in any context expecting a shape.
> Or you can customize lollypop, eg with a longer stick:
>    lollypop(height=20)
> You can accomplish something similar with a module definition, but objects
> are easier to understand and use.
> So lollypop contains two shapes, and behaves like a list of those shapes.
>    len(lollypop) == 2
>    lollypop[0] == translate([0,0,10]) sphere(r=3)
>    lollypop[1] == cylinder(d=1,h=10)
> and this answers what "for (x=lollypop) ..." means.
> Doug.


$  Runsun Pan, PhD 

$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  ) 

$ -- hash parameter model: here , here 

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly 

View this message in context: http://forum.openscad.org/eval-tp12627p12703.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

More information about the Discuss mailing list