forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 1
Oep 1 method to return values from a module
david edited this page Jun 17, 2013
·
2 revisions
a command to allow something along the lines of a :- return([x,y,z],[ax,ay,az]) placed at the end of the module to allow passing of var’s back to the calling code as idealy it should allow for simple use of returning a true/false or extended use of a full xyz and rotation angles on xyz
possible problems i can see would be what to do with the allocation for returned data to keep the var space “clean” and to access the returned data within the calling routine to keep the var space clean the next encounted return() would clear the previous and a matching command say retval([mx,my,mz],[max,may,maz]) where the vars indicate the var to transfer the result in within the calling module
a usage example would be say
module tube(h=10,r1=10,r2=8){ translate([10,100,50])rotate([0,0,45]) difference(){cylinder(h=h*2,r=r1);cylinder(h=(h*2)+1,r=r2);} return([10+(h*2),100,50],[0,0,45]) } module main() { tube(); retval([x,y,z],[ax,ay,az]); echo('object tube ends at 'x,y,z ' with rotation' ax,ay,az ); }
thoughts ?