Jump to content

Change text height, x y position & contents


Recommended Posts

Posted (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 by sivapathasunderam
attached dwg
Posted

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))

 

  • Like 1
Posted

So why this is getting error?

(setpropertyvalue e "Position/X" -2959.684)

 

Posted

I'm not sure, someone else might know though

Posted
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))     

 

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...