Jump to content

Textstyle and Dimstyle


woodman78

Recommended Posts

Thanks Rick,

 

I have tried to put together a Lisp to create a text style and move all the text in a drawing to that style. Here is what I have so far but it creates the textstyle but then stalls. Can you help??

 

 
(defun c:tstyle1 ()
(command "-style" "CCC_Doer" "verdana" "0" "1" "0" "N" "N" "" "")
(setq text1(ssget "x" '((8 . "TEXT"))))
(command "_change" text1 ""  "" "" "CCC_Doer" "" "") 
(princ)
 )

Link to comment
Share on other sites

Assuming your new style exists... use this function...

 

(defun newstyle (name / sset ent lst newlst i)
 (setq sset (ssget "_X" '((0 . "TEXT"))) i 0)
 (repeat (sslength sset)
   (setq ent (ssname sset i))
   (setq lst (entget ent))
   (setq newlst (subst (cons 7 name)(assoc 7 lst) lst))
   (entmod newlst)
   (setq i (1+ i))
 )
)

 

...and call it like this (newstyle "MyNewStyleName")

Link to comment
Share on other sites

Sorry must have picked that up from somewhere along my travels. I have put that into the lisp and it works fine but after it has done everything the command line reads:

 

Command: DOERVER Unknown command "DOERVER". Press F1 for help.

 

 
(defun c:DoerVer (/ *error* Make_Layer Layers obj ss tag)
 (vl-load-com)
 
 
 (setq Layers
     ; Old Color    ; New Layer     ; Layer Color ; Layer Lineweight
        '((5   . ("CCC_DOER_LA0001"     253          "000"))
          (6   . ("CCC_DOER_LA0002"       7          "000"))
          (3   . ("CCC_DOER_LA0003"      84          "030"))
          (1   . ("CCC_DOER_LA0004"       1          "030"))
          (2   . ("CCC_DOER_LA0005"       2          "000"))
          (nil . ("CCC_DOER_LA0006"       7          "000")))
 )
 (setq *doc* (cond (*doc*) ((vla-get-ActiveDocument
                              (vlax-get-acad-object)))))
 (defun *error* (msg)
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))  
 (defun Make_Layer (lay Col LnW)
   (cond (  (tblsearch "LAYER" lay))
          
         (  (setq lObj (vla-add (vla-get-Layers *doc*) lay))
            (vla-put-color lObj Col)
            (vla-put-lineweight lObj
              (eval (read (strcat "acLnWt" LnW)))))))
 (mapcar
   (function
     (lambda (x) (apply (function Make_Layer) (cdr x)))) Layers)
 (if (ssget "_X")
   (progn
     (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *doc*))
       
       (if (setq tag (assoc (vla-get-color obj) Layers))
         (mapcar
           (function
             (lambda (x y) (vlax-put-property obj x y))) '(color layer)
           (list acByLayer (cadr tag))))
       (if (eq "TEXT" (vla-get-layer obj))
         (vla-put-color obj acByLayer)))
     (vla-delete ss)))
(command "_.-layer" "F" "CCC_DOER_LA0005" "F" "LA0000" "")
(command "-style" "CCC_Doer" "verdana" "0" "1" "0" "N" "N" "")
 (setq sset (ssget "_X" '((0 . "TEXT"))) i 0)
 (repeat (sslength sset)
   (setq ent (ssname sset i))
   (setq lst (entget ent))
   (setq newlst (subst (cons 7 "CCC_Doer")(assoc 7 lst) lst))
   (entmod newlst)
   (setq i (1+ i))
(princ)
)
 (princ)
) 

 

It is probably a bracket or something somewhere that I didn't spot but any ideas. I include the dxf to test it.

DOER0002.DXF

Link to comment
Share on other sites

My guess is one two many "" in a command function.

 

Can I ask why you are using (command) to create the style when the (entmake) code was posted above?

 

Styles are especially problematic when using the (command) function because the number of prompts can be different depending on the font selected.

Link to comment
Share on other sites

Well I am trying to get to grips with lisp but i fall down alot with understanding the code very well. I use the command lines as a work around.

 

Anyway I included the entmake and it worked a treat.

 

Thanks.

Link to comment
Share on other sites

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