Author Topic: TextAlignmentPoint vs InsertionPoint  (Read 1957 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
TextAlignmentPoint vs InsertionPoint
« on: December 29, 2016, 01:17:42 AM »
I'm confused between "TextAlignmentPoint" property and "InsertionPoint" property for text.

I have read the AutoCad Documentation help also but still confused.

For TextAlignmentPoint, it says :-
Text: This property will be reset to 0, 0, 0 and will become read-only when the Alignment property is set to acAlignmentLeft. To position text whose justification is left, fit, or aligned, use the InsertionPoint property.


For InertionPoint, it says :
MText: Specifies the location for a corner of the text boundary. Use the AttachmentPoint property to specify which corner of the text boundary is to be positioned at this insertion point.

Text: This property is read-only except for text whose Alignment property is set to acAlignmentLeft, acAlignmentAligned, or acAlignmentFit. To position text whose justification is other than left, aligned, or fit, use the TextAlignmentPoint property.


If anybody can understand it, please explain.



mailmaverick

  • Bull Frog
  • Posts: 493
Re: TextAlignmentPoint vs InsertionPoint
« Reply #1 on: December 29, 2016, 03:28:55 AM »
As per my understanding, I have made the following function. Please correct me if I am wrong :-
Code: [Select]
  (defun ReturnTxtCoords (txtobj / typ ret txtal)
    ;; Returns Text Coordinates for given TEXT object.
    (setq typ (strcase (vla-get-objectname txtobj)))
    (cond ((vl-string-search "MTEXT" typ)
   (setq ret (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint txtobj))))
  )
  ((vl-string-search "TEXT" typ)
   (setq txtal (vla-get-alignment txtobj))
   (if (or (equal txtal acAlignmentLeft) (equal txtal acAlignmentAligned) (equal txtal acAlignmentFit))
     (setq ret (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint txtobj))))
     (setq ret (vlax-safearray->list (vlax-variant-value (vla-get-TextAlignmentPoint txtobj))))
   )
  )
  (T (setq ret nil))
    )
    ret
  )

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: TextAlignmentPoint vs InsertionPoint
« Reply #2 on: December 29, 2016, 04:53:38 AM »
Yes, you understand the theory.
For flexibility (ATTDEF and ATTRIB) I would suggest:
Code - Auto/Visual Lisp: [Select]
  1. (defun ReturnTxtCoords (obj)
  2.   (if
  3.     (and
  4.       (vlax-property-available-p obj 'textalignmentpoint)
  5.       (not (vl-position (vla-get-alignment obj) '(0 3 5))) ; (list acalignmentleft acalignmentaligned acalignmentfit)
  6.     )
  7.     (vlax-get obj 'textalignmentpoint)
  8.     (vlax-get obj 'insertionpoint)
  9.   )
  10. )

David Bethel

  • Swamp Rat
  • Posts: 656
Re: TextAlignmentPoint vs InsertionPoint
« Reply #3 on: December 29, 2016, 08:07:22 AM »
Maybe this will help

AFAIK :

TEXT and ATTDEF are the same with exception that 1 uses group 74, the other group 73

When 72 and 73 = 0, Group 10 is both the insertion point and alignment point, Group 11 read only @ 0,0,0

All other times Group 10 is the calculated by Autocad and is read only.  Group 11 is the alignment point.  It is a very complex calculation.  Taking font definitions, style tables, system variables into consideration.

HTH  -David

I know nothing about MTEXT
R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: TextAlignmentPoint vs InsertionPoint
« Reply #4 on: December 29, 2016, 08:22:54 AM »
A vanilla version:
Code - Auto/Visual Lisp: [Select]
  1. (defun textinsertion ( enx )
  2.     (if (= "MTEXT" (cdr (assoc 0 enx)))
  3.         (cdr (assoc 10 enx))
  4.         (if (or (= 0 (cdr (assoc 72 enx)) (cdr (assoc 73 enx)))
  5.                 (= 0 (cdr (assoc 72 enx)) (cdr (assoc 74 enx)))
  6.             )
  7.             (trans (cdr (assoc 10 enx)) (cdr (assoc 210 enx)) 0)
  8.             (trans (cdr (assoc 11 enx)) (cdr (assoc 210 enx)) 0)
  9.         )
  10.     )
  11. )

mailmaverick

  • Bull Frog
  • Posts: 493
Re: TextAlignmentPoint vs InsertionPoint
« Reply #5 on: December 29, 2016, 11:35:25 PM »
Great explanation David and thanks to all.