3dwannab Posted Saturday at 11:22 AM Share Posted Saturday at 11:22 AM 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 Link to comment Share on other sites More sharing options...
BIGAL Posted Saturday at 09:44 PM Share Posted Saturday at 09:44 PM 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 Link to comment Share on other sites More sharing options...
Tsuky Posted Saturday at 11:26 PM Share Posted Saturday at 11:26 PM 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 Link to comment Share on other sites More sharing options...
3dwannab Posted Sunday at 12:16 PM Author Share Posted Sunday at 12:16 PM 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 Link to comment Share on other sites More sharing options...
Steven P Posted Sunday at 12:46 PM Share Posted Sunday at 12:46 PM 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 Link to comment Share on other sites More sharing options...
3dwannab Posted Sunday at 12:52 PM Author Share Posted Sunday at 12:52 PM Thanks Steven, neat idea. I've got this one sorted with the help of Lee Macs code. 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted Sunday at 10:56 PM Share Posted Sunday at 10:56 PM (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 Sunday at 10:56 PM by BIGAL Quote Link to comment Share on other sites More sharing options...
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.