Jump to content

Recommended Posts

Posted

Hi .I am trying to write a code to change the text size in a drawing filter them by the textstyle

 

(defun C:test (/ scl a ts n th index b1 b c d b2) 
(setq scl (getint "\n Give the scale  (50,100,200,250,500,etc) :")
     (setq a (ssget))                                          
     (setq n (sslength a))                                     
     (setq index 0)                                            
     (repeat n                                                 
          (setq b1 (entget (ssname a index)))                  
          (setq index (+ index 1))                             
          (setq b (assoc 0 b1))                                 
          (if (= "TEXT" (cdr b))                               
               (progn                                         
                    (setq c (assoc 40 b1))                    
		    (setq ts ht)                      
	            (setq d (cons (car c) ts))                 
                    (setq b2 (subst d c b1))                   
                    (entmod b2)                               
               )
          )
     )
  (print)                                                     
)

 

The idea is to change the text size only in model space using as filter the text style

 

1) All the exist text in text style Area and Multy Area  ht = scl * 0.003

2) All the exist text in text style diast  ht = scl * 0.00175

3) All the other text   ht = scl * 0.0025

 

 

 

(command "-style" "Area" "arial.ttf" "0" "1.2" "0" "N" "N" "N")
(command "_.-style" "Multy Area" "arial.ttf" "0" "1" "0" "N" "N" "N")))
(setq ht(* 0.003 scl))

(command "-style" "diast" "wgsimpl.shx" "0" "1.2" "0" "N" "N" "N")
(setq ht(* 0.00175 scl))


(setq ht(* 0.0025 scl))

 

Thanks

Posted (edited)

Please note he doesn't want annotative text because problems when sending files to clients if i remember.

 

(defun C:test (/ scl ss txt style ht)
  (setq scl (abs (getint "\nSet Scale(50,100,200,250,500,etc): "))) ;abs to set number always positive
  (if (setq ss (ssget '((0 . "TEXT"))))  ;filter the selection here no need to test (if (= "TEXT" (cdr b))
    (foreach txt (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq txt (entget txt))
      (setq style (strcase (cdr (assoc 7 txt))))
      (cond
        ((or (eq "AREA" style)(eq "MULTY AREA" style)(eq "DIAST" style))
          (if (eq "DIAST" style)
            (setq ht (cons 40 (* 0.00175 scl)))
            (setq ht (cons 40 (* 0.003 scl)))
          )
          (entmod (subst ht (assoc 40 txt) txt))
        )
        (t ;everything else
          (setq ht (cons 40 (* 0.0025 scl)))
          (entmod (subst ht (assoc 40 txt) txt))
        )
      )
    )
    (prompt "\nNothing Selected")
  )
  (princ)
)

 

Edited by mhupp
  • 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...