LISP help

LISP help

Anonymous
Not applicable
1,247 Views
6 Replies
Message 1 of 7

LISP help

Anonymous
Not applicable
LSP help

Hi i want to make an LSP that can first burst the text in my file and then who can change all the text font to arial narrow 

 

so this is what i have so far, this code can burst the text but not change it. Thanks for help

 

(defun C:NYBURSTLSP (/ flag ss1 ss2 ss3 ss4 entities len count ent ent_data ent_name new_style_name)
(vl-load-com)
(setvar 'TILEMODE 1)
(setq ss1 (ssget "X" '((0 . "INSERT"))))
(sssetfirst nil ss1)
(C:Burst)
(if (setq i -1 ss (ssget "X" '((0 . "MULTILEADER"))))
(while (setq ent (ssname ss (setq i (1+ i))))
(and (vlax-method-applicable-p
(setq obj (vlax-ename->vla-object ent)) 'Explode)
(vla-explode obj))
(entdel ent)))
(princ))
(setq flag (getvar "qaflags"))
(setvar "qaflags" 1)
(setq ss3 (ssget "X" '((8 . "Annotation"))))
(command "explode" ss3 "")
(setq ss4 (ssget "X" '((8 . "0"))))
(command "explode" ss4 "")
(setvar "qaflags" flag)
(princ)

(defun C:ChngFont (/ ss1 entities len count ent ent_data ent_name new_style_name)
(setq flag (getvar "qaflags"))
(setvar "qaflags" 1)
(setq ss1 (ssget "X" '((0 . "MTEXT"))))
(command "explode" ss1 "")
(setvar "qaflags" flag)
(princ)
(command "TILEMODE" "1")
(command "-STYLE" "Arial Narrow" "Arial Narrow" "0" "1" "0" "n" "n")
(setq entities (ssget "X" '((0 . "*TEXT")))
len (sslength entities)
count 0
);setq 

(while (< count len)
(setq ent (ssname entities count) 
ent_data (entget ent)
ent_name (cdr (assoc 7 ent_data))
);setq

(setq new_style_name (cons 7 "Arial Narrow"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while
(setq ArialFont (strcat (getenv "systemroot") "\\Fonts\\Arial.ttf"))

(and
(setq StandardTextSTyle
(vla-item (vla-get-textstyles adoc) "Standard"))
(vlax-write-enabled-p StandardTextSTyle)
(vlax-property-available-p StandardTextSTyle 'Fontfile)
(vlax-put StandardTextSTyle 'Fontfile ArialFont)
)
)

0 Likes
Accepted solutions (4)
1,248 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this and let know

 

(vl-load-com)

(defun C:NYBURSTLSP (/ flag ss1 ss2 ss3 ss4 entities len count ent ent_data ent_name new_style_name otlm)
  
  (setq otlm (getvar 'tilemode))
  (setvar 'TILEMODE 1)
  (setq ss1 (ssget "X" '((0 . "INSERT"))))
  (sssetfirst nil ss1)
  (C:Burst)
  (if (setq i -1 ss (ssget "X" '((0 . "MULTILEADER"))))
    (while (setq ent (ssname ss (setq i (1+ i))))
      (and (vlax-method-applicable-p
             (setq obj (vlax-ename->vla-object ent)) 'Explode)
           (vla-explode obj))
      (entdel ent)))
  
  (if (setq ss3 (ssget "X" '((8 . "Annotation"))))
    (progn
      (initcommandversion)
      (command "explode" ss3 "")))
  
  (if (setq ss4 (ssget "X" '((8 . "0"))))
    (progn
      (initcommandversion)
      (command "explode" ss4 "")))
  
  (if (setq ss1 (ssget "X" '((0 . "MTEXT"))))
    (progn
      (initcommandversion)
      (command "explode" ss1 "")))
  
  (command "-STYLE" "Arial Narrow" "Arial Narrow" "0" "1" "0" "n" "n")
  
  (setq entities (ssget "X" '((0 . "*TEXT")))
        len (sslength entities)
        count 0)
  
  (while (< count len)
    (setq ent (ssname entities count)
          ent_data (entget ent)
          ent_name (cdr (assoc 7 ent_data))
          );setq
    
    (setq new_style_name (cons 7 "Arial Narrow"))
    (setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
    (entmod ent_data)
    (setq count (+ count 1))
    );while
  (setq ArialFont (strcat (getenv "systemroot") "\\Fonts\\Arial.ttf"))
  
  (and
    (setq StandardTextSTyle
           (vla-item (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object))) "Standard"))
    (vlax-write-enabled-p StandardTextSTyle)
    (vlax-property-available-p StandardTextSTyle 'Fontfile)
    (vlax-put StandardTextSTyle 'Fontfile ArialFont)
    )
  
  (setvar 'tilemode otlm)
  (princ)
  )
Message 3 of 7

Anonymous
Not applicable

Didnt work 😕 it says command; error malformed list on input. Thanks for trying

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

It does work. Flawlessly! You need to copy-paste and run the entire code!

0 Likes
Message 5 of 7

Anonymous
Not applicable
Accepted solution

It worked! Thank you so much

0 Likes
Message 6 of 7

Anonymous
Not applicable
Accepted solution

And if i want to make it change the refs that i have in my file to per automatic, can you help me with that? 

0 Likes
Message 7 of 7

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

And if i want to make it change the refs that i have in my file to per automatic, can you help me with that? 


No, to be honest. 

0 Likes