woodman78 Posted January 11, 2010 Share Posted January 11, 2010 Can someone point me to a good lisp to create and set a text style and a dimstyle?? Thanks Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted January 11, 2010 Share Posted January 11, 2010 Quick easy way to create a textstyle... More involved but more adaptable method here, along with a way to create a dimstyle... Quote Link to comment Share on other sites More sharing options...
woodman78 Posted January 11, 2010 Author Share Posted January 11, 2010 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) ) Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted January 11, 2010 Share Posted January 11, 2010 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") Quote Link to comment Share on other sites More sharing options...
woodman78 Posted January 12, 2010 Author Share Posted January 12, 2010 Rick, Does this select and change the text or just select and I do the change as before. Not sure how it fits together. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted January 12, 2010 Share Posted January 12, 2010 Rick? That function will select all TEXT and change it to the style name passed as an argument. Quote Link to comment Share on other sites More sharing options...
woodman78 Posted January 12, 2010 Author Share Posted January 12, 2010 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 Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted January 12, 2010 Share Posted January 12, 2010 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. Quote Link to comment Share on other sites More sharing options...
woodman78 Posted January 13, 2010 Author Share Posted January 13, 2010 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. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted January 13, 2010 Share Posted January 13, 2010 No worries... If you can avoid using (command), do so. (command) is much slower than (entmake) or (vla-add). In fact, if you must use the command line, use the (vl-cmdf) function instead. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.