![]() Here again the changes are highlighted when compared to the previous source code.įor(r=) // it will make 4 versions of the sub-shapesĬhildren(i) // do each of the shapes that come after us Thanks to Openscad's $children feature, we now can factorize both the duplication and the placement of each of the four individual pegs. This problem is highlighted by the weird but required intersection_for() in the official documentation, that will be of no help here though.Ī module as a positioning tool: using the children arrayīack to our PCB holder. The last case occurs because for does an implicit union on the items. Hence, the $children feature does not "see" the individual cubes either (they were merged beforehand)! It does not see the individual sub-shapes! In the following, the cube and the cylinder are seen from within the module as a single child object (which they really are!)Ĭhildren are really only at the top level withing a module!įor the same reason, the iteration below is also one single "unioned" object for the module. Now, a children really is a shape that is "just below" the module. So what is a child now? It is any primitive or composed shape that appear right "under" the module call itself.Ĭheck the example below, where translate_children() iterates on its children, so as to translate each of them on the X axis by a value which is proportional to their order of appearance, before "calling them":Įfficiently translating the "children" of a module proportionally to their order of appearance! This is why I often use a "placement" module for the location of the pegs. It soon becomes very hard to maintain and upgrade such a design! Bug fixes also! Duplicating code adds uninteresting codelines and it is prone to bugs, because a bug fix may be forgotten as the programmer does not know where and how many times the code was duplicated. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |