3dwannab Posted October 19 Posted October 19 Hi all, I'm struggling to set DTEXT justification to bottom centre. I've put the alignment to bottomcenter in the code below but it's the alignment point I'm having difficulty with. MTEXT is much more straight forward it seems. (setq obj (vlax-ename->vla-object (setq en (car (entsel))))) (setq ent (entget en)) (cond ;; If it's TEXT ((eq (cdr (assoc 0 ent)) "TEXT") (princ "\nIS TEXT\n") (vla-put-Alignment obj acAttachmentPointBottomCenter) ;; Having trouble with DTEXT to set the TextAlignmentPoint to bottom center (vla-put-TextAlignmentPoint obj (vlax-3d-point 0 0 0)) ) ;; If it's MTEXT ((eq (cdr (assoc 0 ent)) "MTEXT") (princ "\nIS MTEXT\n") (vla-put-AttachmentPoint obj acAttachmentPointBottomCenter) ) ) Quote
BIGAL Posted October 19 Posted October 19 Try (vla-put-Alignment obj 'acAttachmentPointBottomCenter) You may be able to use a number also 1-9 rather than acAttachmentPointBottomCenter 2 or 8, not tested but works with some VL commands. Quote
Tsuky Posted October 19 Posted October 19 This? (setq obj (vlax-ename->vla-object (setq en (car (entsel))))) (setq ent (entget en)) (cond ;; If it's TEXT ((eq (cdr (assoc 0 ent)) "TEXT") (princ "\nIS TEXT\n") (setq pos (vla-get-InsertionPoint obj)) (vla-put-Alignment obj 13) (vla-put-TextAlignmentPoint obj pos) ) ;; If it's MTEXT ((eq (cdr (assoc 0 ent)) "MTEXT") (princ "\nIS MTEXT\n") (vla-put-AttachmentPoint obj acAttachmentPointBottomCenter) ) ) 1 Quote
3dwannab Posted October 20 Author Posted October 20 12 hours ago, Tsuky said: This? Thanks, yes, it does indeed work but I found a piece of code in Lee Macs DynamicTextAlign program that doesn't change the location of the DTEXT. So full credit to him for that once again. With your example, it shifts the DTEXT to another position. (setq obj (vlax-ename->vla-object (setq en (car (entsel))))) (setq ent (entget en)) (cond ;; If it's TEXT ((eq (cdr (assoc 0 ent)) "TEXT") (princ "\nIS TEXT\n") (vla-put-Rotation obj 0) ;; Set text rotation to 0 (vla-put-Height obj (getvar "textsize")) ;; Set text rotation to 0 ;; Alignment Taken from DynamicTextAlign by LeeMac ;; 8 below is bottomcenter (if (eq AcAlignmentLeft (vla-get-Alignment obj)) (progn (setq tmp (vla-get-InsertionPoint obj)) (vla-put-Alignment obj (+ 8 5)) (vla-put-TextAlignmentPoint obj tmp) ) (vla-put-Alignment obj (+ 8 5)) ) ) ;; If it's MTEXT ((eq (cdr (assoc 0 ent)) "MTEXT") (princ "\nIS MTEXT\n") (vla-put-Rotation obj 0) ;; Set text rotation to 0 (vla-put-Height obj (getvar "textsize")) ;; Set text height to 0 (vla-put-Width obj 0) ;; Set text width to 0 (vla-put-AttachmentPoint obj 8) ) ) 14 hours ago, BIGAL said: (vla-put-Alignment obj 'acAttachmentPointBottomCenter) That's what I did have. It's the vla-put-TextAlignmentPoint which needs to be there to alter the justification after vla-put-Alignment. Quote
Steven P Posted October 20 Posted October 20 Not sure if this is any help, I use these to justify text (single command, example JUBC - JUstify Bottom Centre). Should also work with a single entity rather than a selection set. (defun c:jul() (jut "l")) (defun c:juc() (jut "c")) (defun c:jur() (jut "r")) (defun c:jutl() (jut "tl")) (defun c:jutc() (jut "tc")) (defun c:jutr() (jut "tr")) (defun c:juml() (jut "ml")) (defun c:jumc() (jut "mc")) (defun c:jumr() (jut "mr")) (defun c:jubl() (jut "bl")) (defun c:jubc() (jut "bc")) (defun c:jubr() (jut "br")) ;;https://www.cadtutor.net/forum/topic/35569-text-justification-lisp/ (defun jut (just / ss) (princ (strcat "\nSelect Text")) (if (setq ss (ssget "_:L" '((0 . "ATTDEF,MTEXT,TEXT")))) (command "_.justifytext" ss "" just) ) (princ) ) 1 Quote
3dwannab Posted October 20 Author Posted October 20 Thanks Steven, neat idea. I've got this one sorted with the help of Lee Macs code. 1 Quote
BIGAL Posted October 20 Posted October 20 (edited) Look carefully at these 2 lines they are different. Often a quote is needed. acAttachmentPointBottomCenter 'acAttachmentPointBottomCenter (VLA-PUT-ATTACHMENTPOINT OBJ ACATTACHMENTPOINTBOTTOMCENTER) ; error : bad argument type <NIL> ; expected VLA-OBJECT at [vla-put-attachmentpoint] Edited October 20 by BIGAL 1 Quote
3dwannab Posted October 28 Author Posted October 28 On 10/20/2024 at 11:56 PM, BIGAL said: VLA-PUT-ATTACHMENTPOINT This bit is fine in my code in the starting post. vla-put-AttachmentPoint is for MTEXT only which is working fine. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.