![]() Indeed, any change in the positioning would need to be duplicated. Now there is something annoying: positioning the "positive" peg shapes and the "negative" peg shapes rely on fully duplicated code. And finally carve the pegs (all through the plate itself)įor(r=) // repeat the positioning Plate_th+tol]) // higher to avoid gaps with the pegs! Now call and build the four pegs positive shapes (not carved) Translate() // screw holeĬylinder(r=screw_d/2,h=height+2*tol + plate_th ) // hole The changes are highlighted.Įlse // "negative" shape (carve the inner peg cylinder) Or the module itself could be written with a "positive" and "negative" version like this. It also makes the source code not very readable and less parametric. But it breaks the very idea of a module by sharing "internal" information with the outside (it crosses the module encapsulation). only the cylinders and before the plate is added).Ī way out could be to take the negative (hollow) cylinder out of the module, and remove them to the union of the pegs and the plate. Making holes longer will not help, because they apply only to the shapes defined in the one_peg module (i.e. Plate_th+tol]) // slightly higher to avoid gapsīut when we add the blue bottom plate, flush with the pegs, the holes are no more open! Helper module: centered cube on (X,Y) but not on Z, like cylinder Tol=0.05 // used for CSG subtraction/additionĬylinder(r=screw_d/2,h=height+2*tol) // through hole Screw_dist=40 // PCB hole spacing (square) We conveniently put all these in a "peg" module.īut we want the screws to go all through the support, which itself it added outside of the module.įailed! The peg holes do not go through the blue plate.įorget about the dimensions, we do not care here.Īs we have seen, it is a good practice to factorize the peg shapes into a module, and then to iterate four times on it, like this: Each of the "pegs" is made of a cylinder, a bevel at the base, and a hollow cylinder for the screw. Let us consider a support for an electronic board. This is a common design problem with the constructive solid geometry paradigm. How can "negative" shapes extend outside of their module? Children, factorized placement and chained hulls.Iteration, extrusion and useful parametrized CSG techniques. ![]() Variables and modules for parametric designs.Introduction to constructive solid geometry with OpenSCAD.So in this case faces could be build in one step too. Since openscad 2015-03 faces can have more than 3 points, if all points of the face are on the same plane. Polyhedron(points = points, faces = faces) Points = ) iterate_cs(i)] įaces1 = ) find_neighbours1(i)] įaces2 = ) find_neighbours2(i)] to connect last point on section to first points on the same and the next sectionįunction item_add2(i) = i - p*floor(i/p) >= p-1 ? -p : 0 įunction find_neighbours1(i) = įunction find_neighbours2(i) = to connect point on last section to corresponding points on first sectionįunction item_add1(i) = i >= (s - 1)*p ? -(s)*p : 0 for every point find neighbour points to build faces, ( + p: point on the next cross-section), points ordered clockwise returns the points x-, y-, z-coordinates by rotatating the corresponding point from crossection around the z-axisįunction iterate_cs(i) = ]*cos(360*floor(i/p)/s), cs]*sin(360*floor(i/p)/s), cs]] returns to the index in the points - vector the section number and the number of the point on this sectionįunction point_index(i) = angle = 360*i/p + startangle, x = r2*cos(angle), y = 0, z = r2*sin(angle)įunction cs_point(i) = R2 = 4 // radius of polygon/ thickness of torusĪ = 30 // angle of the first point on Polygon You can control the quality of the surface by the number of points per profile and the distance between the profiles (sectors in torus). Add an appropriate number of points per profile in defined order to a vector „points“, define faces by the indices of the points in a second vector „faces“ and set both vectors as parameter in polyhedron(), see documentation. In Your way You can do this with polyhedron().
0 Comments
Leave a Reply. |