GDL
About building parametric objects with GDL.
SOLVED!

Help with text orientation

matleonii
Booster
Hello everyone! I'm new to GDL and i'm working on a simple object that consist in a 2D symbol.

The idea is to have a circle with a letter in it. I'd love to make the letter always horizontal, but always inside the circle. I guess I should move the rotation point to so the letter rotates on its center, and not in the origin (0,0), but I just could not manage to do so. Is there a way to do this? any help would be awesome!



PS: on the image the blue symbol is the one with no text orientation rule, so you see the text upside down. The red one is with the always horizontal rule, and you see that the object rotates but the letter stays.
This is the code I used for the red one:

DEFINE STYLE "estilo" Arial, txtsize, 7, 0
STYLE estilo

! ------------------------------------------------------------------------------
! Text Rotation - Readable / Always Horizontal / Align with Symbol
! ------------------------------------------------------------------------------
r = request ("View_Rotangle", "", _angleViewRot)

! Actual rotation of the 2D symbol:	
_totalRotate	= (SYMB_ROTANGLE + _angleViewRot) MOD 360

! Count the number of transformations of the 
! coordinate system in different cases
_nTrans = 0					  
 
if iTypeTextRotation = 2 then					! Readable
    if (_totalRotate > (90 + EPS) & _totalRotate < (270 + EPS)) then
        rot2 180
        _nTrans = _nTrans + 1
    endif
else
    if iTypeTextRotation = 1 then				! Horizontal
        rot2 _totalRotate * (SYMB_MIRRORED - not(SYMB_MIRRORED))
        _nTrans = _nTrans + 1
    endif
endif

! ------------------------------------------------------------------------------
! Text
! ------------------------------------------------------------------------------

TEXT2 -0.035,0.04, txt

! ------------------------------------------------------------------------------
! Delete transformation after Text Rotation
! ------------------------------------------------------------------------------
del _nTrans
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
matleonii
Booster
Found it!

I was testing some with the codes and found a solution.

changed the text part so that the origin would rotate with the object and the "unrotate" for the text to get on the right position.

ROT2 -SYMB_ROTANGLE

ADD2 0, 0.1

ROT2 SYMB_ROTANGLE

TEXT2 0 ,0, txt
DEL 1

View solution in original post

4 REPLIES 4
Lingwisyer
Guru
Use Add2 for your transformation before your Text2 command, then set your text to [0, 0]?

You might also need to use a Style command to set your text anchor to center.

ADD2 -0.035, 0.04
TEXT2 0 ,0, txt
DEL 1



Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660 
matleonii
Booster
Lingwisyer wrote:
Use Add2 for your transformation before your Text2 command, then set your text to [0, 0]?

You might also need to use a Style command to set your text anchor to center.

ADD2 -0.035, 0.04
TEXT2 0 ,0, txt
DEL 1



Ling.
Thanks for your reply! But it did not work. the issue kept the same.
Solution
matleonii
Booster
Found it!

I was testing some with the codes and found a solution.

changed the text part so that the origin would rotate with the object and the "unrotate" for the text to get on the right position.

ROT2 -SYMB_ROTANGLE

ADD2 0, 0.1

ROT2 SYMB_ROTANGLE

TEXT2 0 ,0, txt
DEL 1
Lingwisyer
Guru
matleonii wrote:
But it did not work. the issue kept the same.

Works fine for me. I guess I simplified my explanation too much for you as the code line I wrote there is not a straight substitution as you did not provide the full code.

See my test object enc.



Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660