How can I change the code so that it selects all mtexts in the drawing, and applies all changes to them?

How can I change the code so that it selects all mtexts in the drawing, and applies all changes to them?

edushka228
Enthusiast Enthusiast
290 Views
1 Reply
Message 1 of 2

How can I change the code so that it selects all mtexts in the drawing, and applies all changes to them?

edushka228
Enthusiast
Enthusiast

This code requires selecting objects in the drawing, and I need to make it select all objects in the drawing and apply the rest of the code functionality to them:

 

 

(defun c:bmon (/
       ss
       mts
       vl_mts
       mask_on

       mt
       mt_dxf
       leader
      )
  (setq ss (ssget '((0 . "MTEXT"))))
  (setq mts (ssnamex ss))
  (setq ss nil)
  (setq mts (mapcar 'cadr mts))
  (setq mts (vl-remove-if-not '(lambda (x) (eq (type x) 'ENAME)) mts))

  (setq vl_mts (mapcar 'vlax-ename->vla-object mts))

  (mapcar '(lambda (x) (vla-put-BackgroundFill x :vlax-true)) vl_mts)

  (foreach mt mts
    (setq mt_dxf (entget mt))
    (setq mt_dxf (subst (cons 63 256) (assoc 63 mt_dxf) mt_dxf))
    (setq mt_dxf (subst (cons 45 1.25) (assoc 45 mt_dxf) mt_dxf))
    (setq mt_dxf (subst (cons 90 3) (assoc 90 mt_dxf) mt_dxf))
    (entmod mt_dxf)
    (if (assoc 330 mt_dxf)
      (progn
        (setq leader (cdr (assoc 330 mt_dxf)))
(vl-cmdf "_draworder" leader "" "_a" mt "")
      )
    )
      
  )
)

 

0 Likes
Accepted solutions (1)
291 Views
1 Reply
Reply (1)
Message 2 of 2

paullimapa
Mentor
Mentor
Accepted solution

To automatically select all MTEXT

Change this line of code:

(setq ss (ssget '((0 . "MTEXT"))))

To this line of code:

(setq ss (ssget "_X" '((0 . "MTEXT"))))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes