So I created a function that creates a hollow cube by differencing two
cubes. For some reason though it wont compile. I keep getting a syntax
error on the first bracket after the difference function is called. If I
comment out the difference function it works fine. What am I missing here?
You can use the difference function in a user defined function right? If
not how can I create a function to create an object?
function CreateNonArchedBody(boxLength,
boxWidth,
boxHeight,
boxDepth,
boxWallThickness,
boxHingeDiameter,
boxHingePinDiameter,
boxHingeXOffset,
boxHingeYOffset,
boxHingeTolerance,
pinTolerance,
controlArmPinDiameter,
controlArmHoleXOffset,
controlArmHoleYOffset) =
difference() {
cube([boxLength,boxWidth,boxHeight],
center = true
);
translate([0,0,((boxHeight-boxDepth)/2)])
cube([boxLength - boxWallThickness,
boxWidth - boxWallThickness,
boxDepth],
center = true
);
}
--
View this message in context: http://forum.openscad.org/Difference-in-a-Function-Definition-tp12303.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
This should be a module rather than a function. Just change the keyword and
drop the "="
--
View this message in context: http://forum.openscad.org/Difference-in-a-Function-Definition-tp12303p12304.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Oh Thanks that works. What is the difference between the two? What
determines when you use a function vs a module?
--
View this message in context: http://forum.openscad.org/Difference-in-a-Function-Definition-tp12303p12305.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Functions in Openscad are functions in the mathematical sense. They return the solution to an equation rather than creating geometry.
On Friday, April 3, 2015 at 00:07, linkreincarnate wrote:
Oh Thanks that works. What is the difference between the two? What
determines when you use a function vs a module?
--
View this message in context: http://forum.openscad.org/Difference-in-a-Function-Definition-tp12303p12305.html
Sent from the OpenSCAD mailing list archive at Nabble.com (http://Nabble.com).
OpenSCAD mailing list
Discuss@lists.openscad.org (mailto:Discuss@lists.openscad.org)
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
I learned it this way:
a = x; // x is a parameter, previously defined as x=something;
b = x( ); // x is a function
x; // x is a module
So in OpenScad you can have same name x representing 3 different things.
$ 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
$ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.04.01.nightly
--
View this message in context: http://forum.openscad.org/Difference-in-a-Function-Definition-tp12303p12356.html
Sent from the OpenSCAD mailing list archive at Nabble.com.