6
$\begingroup$

How could I get/set the absolute position of an object in geometry node? I could use the Object info and manually select the current object to get its position, but it's tedious to do that if I want to apply it to multiple objects.

I found some workaround below (see my answer), but they are not perfect: they fail when the object is scaled (at least negatively), and require either the existence of dummy objects or I need to manually select the current object.

$\endgroup$

3 Answers 3

4
$\begingroup$

WARNING: if you scale the object, the setter will not work properly. I don't know how to fix that without applying the scale first or using Object Info by manually selection the current object (see last part of the answer, that, unfortunately can't work when the scale is negative).

As far as I know there is no way to get the info of the current object (which is a bit sad, let me know if there is a way to do that). But I found a workaround to get/set the absolute position of an object: add a dummy object to the scene (you can use any object, even if it's location is not at (0,0,0)) and then exploits the Relative/Absolute option of object info: if you know where a given object is located, and how you are related to this object, then it's quite easy to get the current position of the object. Then, you can just translate the object to reinitialize its position to (0,0,0), and translate it again to set its position absolutely:

enter image description here

Demo:

enter image description here

WARNING: if you scale the object, the setter will not work properly. More precisely, the transformation will automatically move towards the dummy object when the scale goes to 0. This is because blender will multiply the position of the points by the scale, so I guess one would need to scale the transformation by the inverse of the scale to balance this effect… unfortunately I know no way to avoid that without manually choosing the current object. And even in that case, this does not work when the scale is negative (even with an abs node) as the scale output of Object info seems to lose the sign of the scale.

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Yes, I ended up with a similar node setup in my answer here: blender.stackexchange.com/questions/257886/… That does involve selecting the current object it doesn't work when the object scale is negative. $\endgroup$
    – David Wood
    May 6, 2022 at 13:29
  • $\begingroup$ @DavidWood Thanks for the confirmation (and link to related answers). I should report this bug for negative scale. $\endgroup$
    – tobiasBora
    May 6, 2022 at 18:42
0
$\begingroup$

I used the node Transform Geometry to do the trick. By scaling it down to zeros for all coordinates and it will shrink to the origin of the geometry.

The best is you still have the original amount of position vector array to match the geometry calculations rather than only one "dot diamond" point left.

Surely, you need to "spare" another geometry to do the scale down for the "acquisition of the location only" trick.

$\endgroup$
1
  • $\begingroup$ Use "Attribute Statistic" node instead. $\endgroup$ Sep 15, 2023 at 11:51
-2
$\begingroup$

I used the Bounding Box Node and took the Min Vector as my object position. You could also use Math nodes to calculate the center of the object using the Min and Max vectors from the Bounding Box node.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .