From 9d48dbf8d5128633c0a507a60b05b2a225a8fb83 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Wed, 6 Nov 2024 22:36:24 -0500 Subject: [PATCH] add example of internal attachment --- attachments.scad | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/attachments.scad b/attachments.scad index e9f0a07..f7da94e 100644 --- a/attachments.scad +++ b/attachments.scad @@ -2759,7 +2759,10 @@ module corner_profile(corners=CORNERS_ALL, except=[], r, d, convexity=10) { // in that color, but if you want to retain control of color for sub-parts of an attachable object, you can use // the `keep_color=true` option, which delays the assignment of colors to the child level. For this to work // correctly, all of the sub-parts of your attachable object must be attachables. Also note that this option could -// be confusing to users who don't understand why color commands are not working on the object. +// be confusing to users who don't understand why color commands are not working on the object. +// . +// Note that anchors created by attachable() are generally intended for use by the user-supplied children of the attachable object, but they +// are available internally and can be used in the object's definition. // . // For a step-by-step explanation of attachments, see the [Attachments Tutorial](Tutorial-Attachments). // @@ -3021,6 +3024,38 @@ module corner_profile(corners=CORNERS_ALL, except=[], r, d, convexity=10) { // recolor("pink") thing() // attach(RIGHT,BOT) // recolor("blue") cyl(d=5,h=5); +// Example(3D,NoScale): This example defines named anchors and then uses them internally in the object definition to make a cutout in the socket() object and to attach the plug on the plug() object. These objects can be connected using the "socket" and "plug" named anchors, which will fit the plug into the socket. +// module socket(anchor, spin, orient) { +// sz = 50; +// prong_size = 10; +// anchors = [ +// named_anchor("socket", [sz/2,.15*sz,.2*sz], RIGHT, 0) +// ]; +// attachable(anchor, spin, orient, size=[sz,sz,sz], anchors=anchors) { +// diff() { +// cuboid(sz); +// tag("remove") attach("socket") zcyl(d=prong_size, h=prong_size*2); +// } +// children(); +// } +// } +// module plug(anchor, spin, orient) { +// sz = 30; +// prong_size = 9.5; +// anchors=[ +// named_anchor("plug", [0,sz/3,sz/2], UP, 0) +// ]; +// attachable(anchor, spin, orient, size=[sz,sz,sz], anchors=anchors) { +// union(){ +// cuboid(sz); +// attach("plug") cyl(d=prong_size, h=prong_size*2,$fn=6); +// } +// children(); +// } +// } +// socket(); +// right(75) plug(); + module attachable( anchor, spin, orient,