sivapathasunderam Posted March 1, 2023 Share Posted March 1, 2023 (edited) I was trying to make default cover page of 20 sections of a Project As I have attached a dwg There was 3 MTexts 1.) Text 1 - Section nos. it will varies but i need to fix it text height & positions to default 2.) Text 2 - Design status, previously all are preliminary design need to change to "Detailed Design" then text size then its positions x y to default 3.) Text 3 - All the previous dates needs to change to current month "MARCH 2023" then text size then it position x y to default I create a lisp that will select each text one by one, but help to fix the error ! (defun c:mycoverpage (/ ss ss1 ss2 e e1 e2 ) (if (setq ss (ssget "_:S" '((0 . "MTEXT")))) (Progn (setq e (ssname ss 0 )) (setpropertyvalue e "TextHeight" 15.00) (setpropertyvalue e "Position/X" -2959.684) (setpropertyvalue e "Position/Y" 730.225) (setpropertyvalue e "Position/Z" 0.00) ) ) (if (setq ss1 (ssget "_:S" '((0 . "MTEXT")))) (Progn (setq e1 (ssname ss1 0 )) (setpropertyvalue e1 "TextHeight" 14.00) (setpropertyvalue e1 "Position/X" -2957.874) (setpropertyvalue e1 "Position/Y" 689.120) (setpropertyvalue e1 "Position/Z" 0.00) (setpropertyvalue e1 "Contents" "\\pxqc;{\\C256;DETAILED DESIGN}") ) ) (if (setq ss2 (ssget "_:S" '((0 . "MTEXT")))) (Progn (setq e (ssname ss2 0 )) (setpropertyvalue e2 "TextHeight" 13.00) (setpropertyvalue e2 "Position/X" -2674.324) (setpropertyvalue e2 "Position/Y" 568.830) (setpropertyvalue e2 "Position/Z" 0.00) (setpropertyvalue e2 "Contents" "{\\fArial|b0|i0|c0|p34;\\C256;MARCH 2023}") ) ) (princ)) Cover Page default setting.dwg Edited March 1, 2023 by sivapathasunderam attached dwg Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 1, 2023 Share Posted March 1, 2023 I think this is your problem: "Position/X I'd be tempted to use entmod instead of setpropertyvalue - see the first text to change as an example, commented out your original lines (defun c:mycoverpage (/ ss ss1 ss2 e e1 e2 ) (if (setq ss (ssget "_:S" '((0 . "MTEXT")))) (Progn (setq ed (entget (ssname ss 0 )) ) (setq ed (subst (cons 40 15) (assoc 40 ed) ed )) (setq ed (subst (cons 10 (list -2959.684 730.225 0)) (assoc 10 ed) ed )) (entmod ed) ; (setq e (ssname ss 0 )) ; (setpropertyvalue e "TextHeight" 15.00) ; (setpropertyvalue e "Position/X" -2959.684) ; (setpropertyvalue e "Position/Y" 730.225) ; (setpropertyvalue e "Position/Z" 0.00) ) ) (if (setq ss1 (ssget "_:S" '((0 . "MTEXT")))) (Progn (setq e1 (ssname ss1 0 )) (setpropertyvalue e1 "TextHeight" 14.00) (setpropertyvalue e1 "Position/X" -2957.874) (setpropertyvalue e1 "Position/Y" 689.120) (setpropertyvalue e1 "Position/Z" 0.00) (setpropertyvalue e1 "Contents" "\\pxqc;{\\C256;DETAILED DESIGN}") ) ) (if (setq ss2 (ssget "_:S" '((0 . "MTEXT")))) (Progn (setq e (ssname ss2 0 )) (setpropertyvalue e2 "TextHeight" 13.00) (setpropertyvalue e2 "Position/X" -2674.324) (setpropertyvalue e2 "Position/Y" 568.830) (setpropertyvalue e2 "Position/Z" 0.00) (setpropertyvalue e2 "Contents" "{\\fArial|b0|i0|c0|p34;\\C256;MARCH 2023}") ) ) (princ)) 1 Quote Link to comment Share on other sites More sharing options...
sivapathasunderam Posted March 1, 2023 Author Share Posted March 1, 2023 So why this is getting error? (setpropertyvalue e "Position/X" -2959.684) Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 1, 2023 Share Posted March 1, 2023 I'm not sure, someone else might know though Quote Link to comment Share on other sites More sharing options...
devitg Posted March 1, 2023 Share Posted March 1, 2023 22 minutes ago, Steven P said: I'm not sure, someone else might know though I really do not know why. But you can use vla-put-insertionpoint (setq e1-obj (vlax-ename->vla-object e1)) (setpropertyvalue e1 "TextHeight" 14.00) (setq position-xyz ( list -2957.874 689.120 0.0)) ; new position (vla-put-InsertionPoint e1-obj (vlax-3d-point position-xyz)) 1 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.