Paragraph/textblock/label text alignment

Home Forums Problems and solutions in GDL Documentation elements, text handling Paragraph/textblock/label text alignment

Viewing 6 reply threads
  • Author
    Posts
    • #2698
      James Murray
      Participant

      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.

      James M

    • #2700
      Csilla Mai
      Keymaster

      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

    • #2701
      James Murray
      Participant

      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

    • #2702
      James Murray
      Participant

      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

    • #2703
      James Murray
      Participant

      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

    • #2706
      Csilla Mai
      Keymaster

      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

    • #2709
      James Murray
      Participant

      Thank you! I don’t know what I was doing wrong but it worked when I rebuilt from your example.

      James M

Viewing 6 reply threads
  • The forum ‘Documentation elements, text handling’ is closed to new topics and replies.