[OpenSCAD] Can I get some code review up in here?

runsun runsun at gmail.com
Mon Apr 13 09:51:52 EDT 2015


Or you can try a little more OOP-ish approach using a hash, in which
parameters are encapsulated in a list, described in details here  :
http://forum.openscad.org/parameterized-models-tp8303p8306.html
<http://forum.openscad.org/parameterized-models-tp8303p8306.html>  
(1)     default = ["Height", 7, "Thickness", 5, "PinDiameter", 2 ...
];Retrieve value: *hash*( default, "Height") ==> 7 // Need function
hash()(2) Then expand default as needed:    boxHinge_opt = default;   
controlArm_opt = *update*( default, [ "Height", 8, "ArmColor", "gray" ... ]
);  // Need function update()...(3) In the module:    module boxHinge(
user_opt=[ ] ){       opt = update( boxHinge_opt, user_opt ); // User can
change them       h = hash( opt, "Height");       ...    }    module
controlArm( user_opt=[ ] ){       opt = update( controlArm_opt, user_opt );      
h = hash( opt, "Height");       ...    }
The hash-like structure is the main parameter model in my own code. With
that I can pack parameters and throw them around all together, reuse them
easily, or update them when needed. It makes complicated model codes much
easier to handle, especially when dealing with objects with multiple level
sub-objects ( like Human.Arms.leftArms.Fingers .... ) 



-----
$  Runsun Pan, PhD 
$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  ) 
$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15 
$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.04.01.nightly 





--
View this message in context: http://forum.openscad.org/Can-I-get-some-code-review-up-in-here-tp12341p12355.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150413/ba92e3ac/attachment-0002.html>


More information about the Discuss mailing list