As already correctly noted in The Kalaakaar's comment, the information about the dimensions of an object is unfortunately not available to you when instantiating it.
The solution would therefore be to obtain this information beforehand.
This is inconvenient and can only be achieved in a roundabout way, but you could solve it like this:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/qMwqf.png)
To get the information about the respective width of an object, I first instantiate all objects along a mesh line here (the distance between the points is irrelevant, but must not be $0$).
Then I create bounding boxes from these instances and scale them so that only one line remains (you have to choose the axis of scaling depending on the orientation of your objects). By realizing these bounding box instances, merging their points and converting them into a curve, I get for each object a curve whose length is exactly equal to the width of an object. So you have the required values and the first part is done.
Then you instantiate the final objects. But since you don't know at this point how many objects will fit along your curve, you have to go the other way around and specify a certain number of objects first. Also, you have to capture the index of the instance to be selected (I assume you want to do this randomly) in the point domain beforehand. With this index, you can now sample the previously captured dimensions after instantiation. In this case, it is simply the length of each spline.
Now you are faced with the task of placing these instances along the curve. To do this, you need the position and the rotation.
Therefore you have to divide the curve into segments beforehand, so that you always get exactly the normal of a curve segment as rotation, and no interpolated values. In this example I achieve this with the trick Curve to Mesh
> Split Edges
> Mesh to Curve
.
To get the position, you accumulate the previously captured values. In this example, all my objects have their center in the middle, so I always have to accumulate half of their width, as well as half of the width of the object in front of them.
Finally, you use the node Sample Curve
and activate the option All Curves, because you have previously divided the curve into segments. The values for Position and Rotation obtained in this way then correspond exactly to the values you are looking for and since we still have instances here, you can use them directly with Translate Instances
and Rotate Instances
.
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/AnhmK.gif)
However, the only unsolved problem remains: Depending on the width of your objects, it can happen at sharp corners of a curve that the instantiated objects protrude beyond the corner, ...but that is another question and would definitely go beyond the scope here.
![](https://cdn.statically.io/img/blend-exchange.com/embedImage.png?bid=6gy6Sxg4)
(Blender 3.5.1+)