Is it possible to obtain the current transformation?

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

Is it possible to obtain the current transformation?

Eric Hazen
Hello Everyone-

I'm wondering if it is possible from within a script to access the
transformation
and rotation which are currently in effect?

For example, if there were a function "GetCurrentTransformMatrix()" one
could do:

   m = GetCurrentTransformMatrix();

   tx = m[0][3];
   ty = m[1][3];
   tz = m[2][3];

The use case is to extract coordinates of a few key points in a complex
model using
the "echo" command.

The reason this isn't trivial is because I have a hierarchy of
sub-assemblies which
all have different translations/rotations, so it is somewhat troublesome to
figure out the final XYZ of points within the sub-assemblies.

Thanks much for any ideas!

-Eric


Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to obtain the current transformation?

lobrien
bump

It would help when refactoring complex objects.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to obtain the current transformation?

thehans
It don't think it really makes sense with the way that OpenSCAD works
to need or even be able to use this information.  If you assigned the
current transformation in some code block to a variable, that variable
is scoped to that block, so what are you going to do with it that you
couldn't do by just inserting some geometry directly into that block
to give it the same transformation?

Also keep in mind you can always add a call to children(); from within
a user-defined module to apply some transformation to "TBD"
later-inserted geometries.

Here is a basic example:

```
$fs = 0.5;
$fa = 0.2;
pole_d = 2;
pole_h = 100;

module pole(d,h) {
  cylinder(d=d,h=h);

  translate([0,0,h]) // put children at top
    children();
}

module flagpole_tip(d) {
  sphere(d=d);
}


// pole module can automatically position children
pole(pole_d, pole_h) {
  flagpole_tip(pole_d*2);
}

// translate the pole along X and children follow
translate([0,50,0]) pole(pole_d, pole_h)
  flagpole_tip(pole_d*2);

```

lobrien, Do you have an example of a script where you think having
this data would help?  There's probably an alternate way of looking at
it that doesn't require "knowing" the transformation like that.
On Mon, Sep 24, 2018 at 4:09 PM lobrien <[hidden email]> wrote:

>
> bump
>
> It would help when refactoring complex objects.
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org