1
Automation Interface, Add-Ins and Tools / Re: Shape Scripts: Text in Subshapes
« on: January 28, 2026, 10:24:45 am »
Hi Guillaume,
If I understand correctly, the third (3rd) and fourth (4th) parameters are relative position values.
But it is tricky to determine actual position to draw a subshape.
The important point is that the calculation of the reference point used for relative values is a bit cumbersome.
In this case, the layouttype is default, this is may be 'TopDown'. In the 'TopDown' type, the 3rd parameter is simple, just relative value from 0. If the 3rd value is -50, the subshape will be drawn 50 point left from the rectangle by the drawnativeshape command. After adding a subshape the reference point will be moved to lower (in the 'TopDown' type). In this case, the second parameter (height) is 50, so the reference point will be 50 (0+50). The Y position for the next subshape will be calculated from 50.
We can understand this behaviour by trying the following script. (and change 4th parameter of the second addsubshape)
addsubshape("test", 50, 50, -50, -50); //1
addsubshape("test", 50, 50, -50, 0); //2
Before the first addsubshape, the reference point is (0, 0), this is default.
By the first addsubshape, the reference point will be (0, 50) because the height (the 2nd parameter of the first addsubshape) is 50.
So, the second addsubshape will be drawn from (-50, 50) - in the 'TopDown' type, the 3rd parameter is just relative point from 0, the 4th parameter is calculated from the current reference point - 50 (the 2nd parameter of the first addsubshape) + 0 (the 4th parameter of the second addsubshape)
It is similar when the layouttype is LeftRight, the X position is relative.
This seems very tricky, but because of this behaviour, we can draw subshapes nicely without 3rd and 4th parameters (addsubshape of 2 parameters is commonly used).
HTH,
If I understand correctly, the third (3rd) and fourth (4th) parameters are relative position values.
But it is tricky to determine actual position to draw a subshape.
The important point is that the calculation of the reference point used for relative values is a bit cumbersome.
In this case, the layouttype is default, this is may be 'TopDown'. In the 'TopDown' type, the 3rd parameter is simple, just relative value from 0. If the 3rd value is -50, the subshape will be drawn 50 point left from the rectangle by the drawnativeshape command. After adding a subshape the reference point will be moved to lower (in the 'TopDown' type). In this case, the second parameter (height) is 50, so the reference point will be 50 (0+50). The Y position for the next subshape will be calculated from 50.
We can understand this behaviour by trying the following script. (and change 4th parameter of the second addsubshape)
addsubshape("test", 50, 50, -50, -50); //1
addsubshape("test", 50, 50, -50, 0); //2
Before the first addsubshape, the reference point is (0, 0), this is default.
By the first addsubshape, the reference point will be (0, 50) because the height (the 2nd parameter of the first addsubshape) is 50.
So, the second addsubshape will be drawn from (-50, 50) - in the 'TopDown' type, the 3rd parameter is just relative point from 0, the 4th parameter is calculated from the current reference point - 50 (the 2nd parameter of the first addsubshape) + 0 (the 4th parameter of the second addsubshape)
It is similar when the layouttype is LeftRight, the X position is relative.
This seems very tricky, but because of this behaviour, we can draw subshapes nicely without 3rd and 4th parameters (addsubshape of 2 parameters is commonly used).
HTH,
