The following expression is evaluated in context of the let assignments and can use the variables. Sequential assignment of variables inside an expression. size is a vector, (could be a string but that would be stupid)ĭoIt() // similar to cube(5) v's cube() This is useful when handling parameters to a module, similar to how shapes can be defined as a single number, or as an vector i.e. Note that the len() function is not defined when a simple variable is passed as the parameter. This function allows (e.g.) the parsing of an array, a vector or a string. Usage examples: str1="abcdef" len_str1=len(str1) Īrray1= len_array1=len(array1) Īrray2=,] len_array2=len(array2) ĮCHO:, ,, ], 4 Returns the length of an array, a vector or a string parameter. See: Floor Function echo(floor(4.4),floor(-4.4)) // produces ECHO: 4, -5 floor(x) = is the largest integer not greater than x Returns the base-e exponential function of x, which is the number e raised to the power x. Usage examples: echo(cross(, )) // produces ECHO: Įcho(cross(, )) // produces ECHO: Įcho(cross(, )) // produces ECHO: 8Įcho(cross(, )) // produces ECHO: 17Įcho(cross(, )) // produces ECHO: undefĮcho(cross(, "5")) // produces ECHO: undefįor any two vectors a and b in 2D or in 3D, the following holds: Using any other types, vectors with lengths different from 2 or 3, or vectors not of the same length produces 'undef'. Note that this is the determinant of the 2x2 matrix ,]. If both vectors are in 2D space, their cross product has the form and the cross function returns just the z value of the cross product: If both vectors are in the 3D, the result is a vector that is perpendicular to both of the input vectors. Polygon(concat(,], ])) Įcho(concat("abc","def")) // produces ECHO: Įcho(str("abc","def")) // produces ECHO: "abcdef"Ĭalculates the cross product of two vectors in 3D or 2D space. in the exmple below, a fourth point is added to the polygon path, which used to resemble a triangle, making it a square now: an extra set of brackets) before the concatenation. When adding something like a single element tuples (which are vectors, too), the tuple needs to be enclosed in a vector (i.e. Note: All vectors passed to the function lose one nesting level. Strings are distinct from vectors in this case.
Where an argument is a vector the elements of the vector are individually appended to the result vector. Return a new vector that is the result of appending the elements of the supplied vectors. Returns the next highest integer value by rounding up value if necessary. Returns the positive value of a signed decimal number. Openscad and its language and GUI would be absolutely perfect if only I could do that one kind of statements.Other Mathematical Functions Edit abs Edit I also looked into CadQuery now but to be perfectly honest I have no idea what I'm looking at, and it doesn't really seem like it would be very suited to do what I want either. I believe I tried ImplicitCad which seems to be 100% code-compatible with Openscad except it does allow the z = z+1 like you would expect from normal programming languages, but obviously it isn't very practical to use and when the geometry gets very complex with a lot of polygons it doesn't seem to handle it very well. One solution that comes to mind would be just having a formula that uses the i variable which in this case would just be z = i but once again I'm not dealing with simple linear changes like that, and frankly I don't even know what kind of equations and formulas I would need to use to get the results I want without the for loop just "remembering" what it did last time (the result is a 3D spiral/helix that has the spacing and diameter of its coils progressively changing as it gets taller in a non-linear way). This would be extremely easy to do if z = z+1 actually worked as expected, which it sadly doesn't. Obviously this example doesn't make much sense but in my case I have multiple different variables that need to be recalculated every time the for loop is ran and that depend on the results of the previous for loop.
I'm not sure how to describe it properly fundamentally I want to do something like I want to make a parametric model for 3D printing that makes heavy use of constantly changing dimensions of meshes based on the position and dimensions of meshes before them.