Home › Forums › Problems and solutions in GDL › Documentation elements, text handling › Paragraph/textblock/label text alignment
- This topic has 6 replies, 2 voices, and was last updated 8 years, 2 months ago by James Murray.
-
AuthorPosts
-
-
September 8, 2016 at 15:30 #2698James MurrayParticipant
Is there a way to have a paragraph + textblock + richtext automatically justify right or left, depending on which direction the label is drawn? I have experimented with the relevant paragraph and textblock parameters without success. It seems we have to use LABEL_TEXT_ALIGN for the paragraph alignment value, and then adjust the alignment manually in label settings. FWIW, I don’t see the Archicad library labels handing it any better. In the attached image, both labels are left aligned in settings. The label on the left should be right aligned, ideally without going to settings.
Attachments:
James M
-
September 8, 2016 at 17:32 #2700Csilla MaiKeymaster
Hi James,
If the Pointer is drawn by ARCHICAD (the LABEL_CUSTOM_ARROW global is 0), the LABEL_POSITION[2][1] global gives back the Pointer’s horizontal width depending on the actual connection side with the Label symbol. You can use this value with the SGN() function to define the text alignment in the paragraph and textblock commands by the sign of the width value.
Csilla Mai
Library Developer, Library Team
GRAPHISOFT SE -
September 8, 2016 at 19:06 #2701James MurrayParticipant
Hi Csilla, thanks for the reply, that is the sort of thing I am looking for. But I’m not seeing that result from looking at [2][1]. It seems to always be negative. The only consistent sign change I can see between right and left sides is at [2][2] – it is always zero for labels on the right, and always non-zero for the left. But unfortunately, the non-zero values are extremely tiny (e-16 or 17!) and it seems strange to evaluate for such a difference with zero. Or, should I go ahead and do
IF ABS(connectionSide-0)<0.000000000000000001 THEN...
Thanks again.James M
-
September 8, 2016 at 19:07 #2702James MurrayParticipant
Signs of all the array cells for labels in four quadrants:
Upper right [ 1 ][ 1 ] 1 () [ 1 ][ 2 ] 1 () [ 2 ][ 1 ] -1 () [ 2 ][ 2 ] 0 () [ 3 ][ 1 ] -1 () [ 3 ][ 2 ] -1 () Lower right [ 1 ][ 1 ] 1 () [ 1 ][ 2 ] 1 () [ 2 ][ 1 ] -1 () [ 2 ][ 2 ] 0 () [ 3 ][ 1 ] -1 () [ 3 ][ 2 ] 1 () Upper left [ 1 ][ 1 ] 1 () [ 1 ][ 2 ] 1 () [ 2 ][ 1 ] -1 () [ 2 ][ 2 ] 1 () [ 3 ][ 1 ] -1 () [ 3 ][ 2 ] 1 () Lower left [ 1 ][ 1 ] 1 () [ 1 ][ 2 ] 1 () [ 2 ][ 1 ] -1 () [ 2 ][ 2 ] 1 () [ 3 ][ 1 ] -1 () [ 3 ][ 2 ] -1 ()
James M
-
September 8, 2016 at 19:23 #2703James MurrayParticipant
That tiny difference can be evaluated, but now I see that changing the paragraph alignment and text block anchor seems to have no effect when the label is connected on the left. I’m using 3 for the paragraph alignment, and 6 for the textblock anchor. But the text looks the same as when I use 1 and for the right-side version.
James M
-
September 9, 2016 at 10:56 #2706Csilla MaiKeymaster
Hi James,
I hope this short script will help you with the alignment problem:
! fontType and fontSize are parameters define style{2} "NormalStyle" fontType, fontSize, 0 style "NormalStyle" if sgn(LABEL_POSITION[2][1]) = -1 then _iAlign = 3 else _iAlign = 1 endif paragraph "paragraphName" _iAlign, 0, 0, 0, 1 style "NormalStyle" "sample Text of Label" endparagraph _textblockWidth = 7 ! Just for example textblock "stTextblockName" _textblockWidth, 1, 0, 1, 1, 0, "paragraphName" richtext2 0, 0, "stTextblockName"
It results the behaviour you can see on the attached picture. If it does not solve your problem, please upload the 2D script or the object which you are working on.
Attachments:
Csilla Mai
Library Developer, Library Team
GRAPHISOFT SE -
September 9, 2016 at 16:33 #2709James MurrayParticipant
Thank you! I don’t know what I was doing wrong but it worked when I rebuilt from your example.
James M
-
-
AuthorPosts
- The forum ‘Documentation elements, text handling’ is closed to new topics and replies.