Guest Posted November 9, 2022 Share Posted November 9, 2022 Hi. I am using this code ; ROTOTXT.LSP ; Routine for rotating text to a the current viewtwist angle. ; ; (defun c:ROV ( / ss2 i vta tmp) (vl-load-com) (prompt "\n Select TEXT and MTEXT to rotate ") (setq ss2 (ssget '((0 . "*TEXT"))) i 0 vta (- 0 (getvar "viewtwist")) ) (repeat (sslength ss2) (setq tmp (vlax-ename->vla-object (ssname ss2 i))) (if (eq (vla-get-ObjectName tmp) "AcDbText") (progn (vlax-put tmp "Rotation" vta) (vlax-put tmp "Alignment" acAlignmentLeft) ) (progn (vlax-put tmp "Rotation" 0.0) (vlax-put tmp "AttachmentPoint" acAttachmentPointTopLeft) ) ) (setq i (1+ i)) ) ) To rotate text to a the current viewtwist angle. I want to change this code to automatic select specific layer of text,mtext, and block and rotate them to a the current viewtwist angle i try to change this line (setq ss2 (ssget '((0 . "*TEXT"))) with this (setq ss2(ssget "_X" ((0 . "INSERT") (0 . "*TEXT") (8 . "LAYER1,LAYER2,LAYER3"))) but is not working. Can any one help? Thanks Quote Link to comment Share on other sites More sharing options...
mhupp Posted November 9, 2022 Share Posted November 9, 2022 You need to use Logical Operators http://lee-mac.com/ssget.html#logical (setq ss2 (ssget "_X" '((-4 . "<OR") (0 . "INSERT") (0 . "*TEXT") (-4 . "OR>") (8 . "LAYER1,LAYER2,LAYER3"))) 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 9, 2022 Share Posted November 9, 2022 Or simply: (setq ss2 (ssget "_X" ((0 . "INSERT,*TEXT") (8 . "LAYER1,LAYER2,LAYER3")))) 1 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2022 Share Posted November 9, 2022 (edited) hI mhupp . I test your code and i have this error . Quote ; error: ActiveX Server returned the error: unknown name: "AttachmentPoint" (defun c:ROV2 ( / ss2 i vta tmp) (vl-load-com) (setq ss2 (ssget "_X" '((-4 . "<OR") (0 . "INSERT") (0 . "*TEXT") (-4 . "OR>") (8 . "LAYER1,LAYER2,LAYER3"))) i 0 vta (- 0 (getvar "viewtwist")) ) (repeat (sslength ss2) (setq tmp (vlax-ename->vla-object (ssname ss2 i))) (if (eq (vla-get-ObjectName tmp) "AcDbText") (progn (vlax-put tmp "Rotation" vta) (vlax-put tmp "Alignment" acAlignmentLeft) ) (progn (vlax-put tmp "Rotation" 0.0) (vlax-put tmp "AttachmentPoint" acAttachmentPointTopLeft) ) ) (setq i (1+ i)) ) ) Edited November 9, 2022 by prodromosm Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 9, 2022 Share Posted November 9, 2022 5 minutes ago, prodromosm said: hI mhupp . I test your code and i have this error . (defun c:ROV2 ( / ss2 i vta tmp) (vl-load-com) (setq ss2 (ssget "_X" '((-4 . "<OR") (0 . "INSERT") (0 . "*TEXT") (-4 . "OR>") (8 . "LAYER1,LAYER2,LAYER3"))) i 0 vta (- 0 (getvar "viewtwist")) ) (repeat (sslength ss2) (setq tmp (vlax-ename->vla-object (ssname ss2 i))) (if (eq (vla-get-ObjectName tmp) "AcDbText") (progn (vlax-put tmp "Rotation" vta) (vlax-put tmp "Alignment" acAlignmentLeft) ) (progn (vlax-put tmp "Rotation" 0.0) (vlax-put tmp "AttachmentPoint" acAttachmentPointTopLeft) ) ) (setq i (1+ i)) ) ) Go through the logic .. it's a simple IF statement. Would you expect a block to have an attachment point? Quote Link to comment Share on other sites More sharing options...
Guest Posted November 9, 2022 Share Posted November 9, 2022 Yes, but i want to work for text , mtext and block. How to do this !!!! Thanks Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 9, 2022 Share Posted November 9, 2022 Try to figure it out !!! You have 900 posts here and almost 400 at TheSwamp. This problem should be fairly easy for you to solve by now IMO. Quote Link to comment Share on other sites More sharing options...
mhupp Posted November 9, 2022 Share Posted November 9, 2022 (edited) On 11/9/2022 at 4:14 PM, prodromosm said: Yes, but i want to work for text , mtext and block. How to do this !!!! Thanks To get you started. switch the if statement to cond (defun c:ROV2 ( / ss2 i vta tmp) (vl-load-com) (setq ss2 (ssget "_X" '((0 . "INSERT,*TEXT") (8 . "LAYER1,LAYER2,LAYER3"))) vta (- 0 (getvar "viewtwist")) ) (foreach ent (mapcar 'cadr (ssnamex SS2)) (setq tmp (vlax-ename->vla-object ent)) (cond ((eq (vla-get-ObjectName tmp) "AcDbText") (vlax-put tmp "Rotation" vta) (vlax-put tmp "Alignment" acAlignmentLeft) ) ((eq (vla-get-ObjectName tmp) "AcDb ") ;mtext (vlax-put tmp "Rotation" 0.0) (vlax-put tmp "AttachmentPoint" acAttachmentPointTopLeft) ) ((eq (vla-get-ObjectName tmp) "AcDb ") ;block (vlax-put tmp "Rotation" vta) (vlax-put tmp ) ;insertion point? ) ) ) (princ) ) Edited November 11, 2022 by mhupp Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 9, 2022 Share Posted November 9, 2022 Agree with ronjonp, at some point "I want" "I want" has to stop. Its not like your asking for help to solve a difficult problem, I ask at times and I have been at it for over 40 years. Quote Link to comment Share on other sites More sharing options...
Guest Posted November 11, 2022 Share Posted November 11, 2022 Hi can any one help me how to make this code to work for text and mtext ? (defun c:ROV2 ( / ss2 i vta tmp) (vl-load-com) (setq ss2 (ssget "_X" '((0 . "*TEXT,MTEXT") (8 . "LAYER1,LAYER2,LAYER3"))) i 0 vta (- 0 (getvar "viewtwist")) ) (repeat (sslength ss2) (setq tmp (vlax-ename->vla-object (ssname ss2 i))) (if (eq (vla-get-ObjectName tmp) "AcDbText") (progn (vlax-put tmp "Rotation" vta) (vlax-put tmp "Alignment" acAlignmentLeft) ) (progn (vlax-put tmp "Rotation" 0.0) (vlax-put tmp "AttachmentPoint" acAttachmentPointTopLeft) ) ) (setq i (1+ i)) ) ) ;end defun Thanks Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 11, 2022 Share Posted November 11, 2022 Didn't you see @mhupp post? It only needs 2-3 changes. Quote Link to comment Share on other sites More sharing options...
Guest Posted November 11, 2022 Share Posted November 11, 2022 Yes i see it. I think tha this not incluse mtext Quote (setq ss2 (ssget "_X" '((0 . "INSERT,*TEXT") (0 . "*TEXT") (8 . "LAYER1,LAYER2,LAYER3"))) and here i try ((eq (vla-get-ObjectName tmp) "AcDbMTEXT") ;mtext (vlax-put tmp "Rotation" 0.0) (vlax-put tmp "AttachmentPoint" acAttachmentPointTopLeft) ) but didn't work. I don't know Thanks Quote Link to comment Share on other sites More sharing options...
mhupp Posted November 11, 2022 Share Posted November 11, 2022 I Messed up the ssget (setq ss2 (ssget "_X" '((0 . "INSERT,*TEXT") (8 . "LAYER1,LAYER2,LAYER3"))) "AcDbBlockReference" for blocks "AcDbMText" for Mtext 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.