Compare commits

...

3 commits

Author SHA1 Message Date
Christopher Hotchkiss
7b466df29d
Merge 3872625412 into eccdecca4f 2024-10-23 22:14:16 -04:00
Christopher Hotchkiss
3872625412 Reverted my first edit and added an example to detail the nuance 2024-10-10 19:08:11 -07:00
Christopher Hotchkiss
ed525909d3
Update attachments.scad, fix tag_scope example
tag_scope only works if its used inside attachable which is the opposite of the documentation example
2024-10-02 16:35:14 -07:00

View file

@ -1256,7 +1256,7 @@ module default_tag(tag,do_tag=true)
// Note that if you directly set the `$tag` variable then tag scoping will not work correctly. // Note that if you directly set the `$tag` variable then tag scoping will not work correctly.
// Side Effects: // Side Effects:
// `$tag_prefix` is set to the value of `scope=` if given, otherwise is set to a random string. // `$tag_prefix` is set to the value of `scope=` if given, otherwise is set to a random string.
// Example: In this example the ring module uses "remove" tags which will conflict with use of the same tags by the parent. // Example: In this example the ring module uses "remove" tags which will conflict with use of the same tags by the parent without tag_scope.
// module ring(r,h,w=1,anchor,spin,orient) // module ring(r,h,w=1,anchor,spin,orient)
// { // {
// tag_scope("ringscope") // tag_scope("ringscope")
@ -1279,6 +1279,56 @@ module default_tag(tag,do_tag=true)
// tag("rem")ring(9.5,8,w=.3); // tag("rem")ring(9.5,8,w=.3);
// } // }
// } // }
// Example: tag_scope can interact unexpectedly with attachable() depending on if you place it before attachable() or just inside it. If placed outside, the tag_scope will also apply to the attachable's children(). If placed inside it will only apply to the attachable's parent object.
// module outside_attachable(){
// tag_scope("outside_attachable")
// attachable(anchor=CENTER, spin=0, d=60, l=60) {
// color_this("white")
// diff()
// cyl(d=60, l=60){
//
// tag("remove")
// color_this("red")
// cyl(d=30, l=61);
// }
// children();
// }
// }
//
// module inside_attachable(){
// attachable(anchor=CENTER, spin=0, d=60, l=60) {
// tag_scope("inside_attachable")
// color_this("green")
// diff()
// cyl(d=60, l=60){
// tag("remove")
// color_this("blue")
// cyl(d=30, l=61);
// }
// children();
// }
// }
//
// diff()
// outside_attachable(){
// color_this("orange")
// cyl(d=20, l=61){
// tag("remove")
// color_this("yellow")
// cyl(d=10, l=65);
// }
// }
//
// right(60)
// diff()
// inside_attachable(){
// color_this("orange")
// cyl(d=20, l=61){
// tag("remove")
// color_this("yellow")
// cyl(d=10, l=65);
// }
// }
module tag_scope(scope){ module tag_scope(scope){
req_children($children); req_children($children);
scope = is_undef(scope) ? rand_str(20) : scope; scope = is_undef(scope) ? rand_str(20) : scope;