Finding the location of unrelated modules : Module Anchors

classic Classic list List threaded Threaded
2 messages Options
Ivo
Reply | Threaded
Open this post in threaded view
|

Finding the location of unrelated modules : Module Anchors

Ivo
Occasionally i'd like to construct geometries using the final and transformed coordinates of other geometries.

You can duplicate the stack of translates and rotations that led to the location of the required module but that is a very cumbersome solution.

I'd like to be able to so something like :

module Foo() {
  translate([10,5,3]) sphere(10);      // a geometry we are interested in
  anchor("centersphere", [10,5,3]);   // an anchor for a coordinate in this module with a
                                                  //name
};

module Bar(h,w) {
  translate([0,0,h]) size([w,w,1]) Foo();  // we do hard to track stuff with this sub module
}

module Bob() {
  translate([1,1,3]) child(0);
}

module Connector(from, to) { .. from and to are coordinates..}

union() {
  Bob() { Bar(5,6); }
  Connector([1,1,1], anchorlookup("centersphere"));  
   // lookup the transformed coordiantes of this anchor.
   // and draw a line between [1,1,1] and the transformed coordinate
}

The anchor object is transformed the same way the module it resides in is.

I realize there are all sorts issues with this proposal. The syntax is ugly, and the achorlookup can only be done from certain positions in the tree relative to where the anchor is. The geometry of the anchor is also problematic, a point won't tell you the object has rotated.

The are a couple of great proposals for highlighting objects in the viewer and sourcecode  and showing the relationship, maybe this mechanism with unique IDs for geometries could be reused.
Reply | Threaded
Open this post in threaded view
|

Re: Finding the location of unrelated modules : Module Anchors

Johannes Reinhardt
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 11 Mar 2014 12:53:21 -0700 (PDT)
Ivo <[hidden email]> wrote:

> Occasionally i'd like to construct geometries using the final and
> transformed coordinates of other geometries.
>
> You can duplicate the stack of translates and rotations that led to
> the location of the required module but that is a very cumbersome
> solution.
>
> I'd like to be able to so something like :
>
> module Foo() {
>   translate([10,5,3]) sphere(10);      // a geometry we are
> interested in anchor("centersphere", [10,5,3]);   // an anchor for a
> coordinate in this module with a
>                                                   //name
> };
>
> module Bar(h,w) {
>   translate([0,0,h]) size([w,w,1]) Foo();  // we do hard to track
> stuff with this sub module
> }
>
> module Bob() {
>   translate([1,1,3]) child(0);
> }
>
> module Connector(from, to) { .. from and to are coordinates..}
>
> union() {
>   Bob() { Bar(5,6); }
>   Connector([1,1,1], anchorlookup("centersphere"));  
>    // lookup the transformed coordiantes of this anchor.
>    // and draw a line between [1,1,1] and the transformed coordinate
> }
>
> The anchor object is transformed the same way the module it resides
> in is.
>

I just replied to your message in the other thread with an advertisement
for local.scad, but for searchability I duplicate this here:

https://github.com/jreinhardt/local-scad

Tries to do more or less what you describe.

>
>
>
> --
> View this message in context:
> http://forum.openscad.org/Finding-the-location-of-unrelated-modules-Module-Anchors-tp7232.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
> _______________________________________________ OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566



- --

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBAgAGBQJTIBDWAAoJED3c2393ksVEQIEP/imEUsZjwKX+X+a7AeHfO2P/
7g6bJOGvGdhtbnx/wG8E2e+xLv13kH/QLgIFQ+IyijkyhJ//1pzdYYgSzyjz2SgM
Z5+0assiG5J0D0tWfqPCGmxzK7tnWwW8w/EYIkF2gvHomQ95hatHMd4iiaVieMap
hOGjBubNYPMjaPCZ2J7mbqDLtPAmmNicX1wj7wYAa5y4Ra6IuBhbStP8xF1JiJoJ
6hlTS4VIkXo01pEnyQwgnBAjkO89wAw8CKQ4CsQWRGxs4DVWv1h/kadxlaxKVSAJ
5+vI9FBwfErEwh/D9dQTVJ6+lRdUhlX9H/LLxdmZeHx5wOVzuiNMvzy/vNjtLhjj
4+7i3Ql5r9QGVa3IikoIM9hlGIZduw+f0tUJs1n5oQTr+3nhrQwSV1c+CJeM8Umb
zzbjCOXjqKO0KwCHvKXj5A0wsGX8a4O4z5Nw0OockBMxpgOn8hAxC6F+6L3ASH/U
2IxMLc57PA9AkPFDz5y+18Jvr2FupYDusICxYnjC2qmjI2TUq0gGFpGnuCyAMeaU
WsjIVspYU9d817N9GG12tDZDiFhcIj6nQXshfWNkoWwgzQEk/uHOBNanVpJhAD9v
p4WATELLuPGshMwidEm4bi8LaY/KoR3m7RM7J1ny4EthbUksGHOM8MoF4GPnNJVm
aaZPetHaPT88QSJNWNMY
=u4x9
-----END PGP SIGNATURE-----
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566