Replies: 2 comments 1 reply
-
Hey again! 👋 Still diving deep into anchor aliasing — no replies yet, so I wanted to post an update with my latest findings in case anyone can point me in the right direction or help clarify whether I'm on the right path. 🧠 TL;DR I'm trying to create a system where a module can alias or clone an existing anchor (e.g., 🔍 Latest Observations After re-reading the Attachments Tutorial about 10 times, I found a few things that seem promising:
What I really want is:
Fundamentally, a "pass-through with just a few additions or modifications to the anchor" is in a nutshell the capability I am trying to perform. I would have expected information like this to appear after this section in the tutorial: pass-through attachables. At this point I am looking through the source code, and experimenting on how to override the special variables that are used to store include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
// Define a reusable inlet tube with an arc path and a circular cross-section.
module inlet_tube(anchor=CENTER, spin=0, orient=TOP) {
// ❌ This fails: named_anchor requires a numeric position (vector), not a symbolic reference.
a = named_anchor("inlet1", "start-centroid");
// ❌ This also fails: _find_anchor is evaluated *immediately*,
// before the child geometry has populated $parent_geom.
// We would want this to be deferred until after children() executes.
// a2 = _find_anchor("start-centroid", $parent_geom)[1];
attachable(anchor, spin, orient, expose_tags=true){
path = arc(r=50, angle=90);
path_sweep(circle(r=5), path)
// Try to capture anchors *after* geometry is created using parent()
let (
desc = parent(),
a = last(desc[1]),
a1 = _find_anchor("start-centroid", $parent_geom)[1],
a2 = [named_anchor("inlet1", "start-centroid")],
a3 = [named_anchor("inlet1", a1)],
parent_anchors = concat(a, a3),
$parent_anchors = parent_anchors,
$anchor_override = parent_anchors,
$parent_geom = parent_anchors
)
echo("Find anchor, parent_geom", a1)
echo("Named anchor, symbolic", a2)
echo("Named anchor, symbolic resolved", a3)
echo("Concatenated, desc+unresolved", concat(a, a2))
echo("Concatenated, desc+resolved", concat(a, a3));
children();
}
}
// Anchors are centered, not working...
inlet_tube()
echo("Final Anchors", last($parent_geom))
show_anchors();
// Attempt to generate a list of numbered inlet anchor names
inlets = [for (i=[1:10]) str_join(["inlet", i])];
echo(inlets); These functions also look like they might be useful: Lines 5049 to 5088 in 4f0b7e5 🤔 Remaining Questions
|
Beta Was this translation helpful? Give feedback.
-
Try the above. If this solves the problem we can add it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🧵 TL;DR
I'm trying to automate anchor aliasing, and want to know:
named_anchor("name", "existing-name")
?❓ Problem Statement
I'm building a dynamic module that needs to generate reusable, programmatically named anchors for downstream attach() calls — especially for patterns like inlet1, inlet2, etc.
I’d like to alias or clone an existing anchor (e.g. "start-centroid") to a new name (e.g. "inletN") inside a module, so the caller can easily attach to custom-named positions.
However, BOSL2’s current anchor system doesn’t seem to support deferred anchor aliasing (there is also a strong probability that I have absolutely no idea what I am doing). Specifically:
⚙️ Desired Behavior
I’d love to be able to do something like this inside a module:
Or possibly support deferred execution of
_find_anchor(...)
that only triggers after children() have rendered.I looked at the source for
named_anchor
, and it looks like it needs a numeric[pos]
BOSL2/attachments.scad
Lines 3302 to 3319 in 4f0b7e5
Is it a bad idea to just check if
[pos]
is a string, and if so, call_find_anchor(pos)
?🤔 Questions
💡 Use Case
I'm building complex parametric components like duct joiners or manifolds with N inlets and 1 outlet. I want each inlet to expose a clearly named anchor like "inlet1", "inlet2", etc. for other modules to attach to. This makes downstream composition and GUI parameterization in tools like the OpenSCAD customizer much cleaner.
Regards,
Aeonik
Beta Was this translation helpful? Give feedback.
All reactions