I am new to the idea of LISPs, and to be honest I am not entirely sure how to create them. I used the Autodesk answers and it doesn't explain how to do it.
I hoped someone could explain to me how to create them, and secondly can/has anyone created a LISP that can combine font styles?
Thanks in advance!
Solved! Go to Solution.
Solved by ec-cad. Go to Solution.
Not sure what you try to accomplish? Do you have a drawing with many text styles and want all texts to use the same text style?
In short, yes, I have a lot of drawings I didn't create that have loads of text styles in them. Most I can figure out and delete, but there are others in blocks that I need. And I just wondered if there was a way I could merge text styles into one rather than trying to change to texts in the block.
I just wondered if there was a way to create a LISP that could merge the text styles. I have never used these before so am unsure how they work?
If the different Text Styles are all used within various Blocks then you cannot merge them.
You could try this to change all styles to standard ( untested ). That would be a merge of sorts 😀
(defun c:foo (/ a d)
(vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
(cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
)
(vlax-for b (vla-get-blocks d)
(vlax-for o b
(if (vlax-property-available-p o 'stylename)
(vl-catch-all-apply 'vla-put-stylename (list o "STANDARD"))
)
)
)
(foreach l a (vlax-put l 'lock -1))
(vla-regen d acallviewports)
(princ)
)
If there are attributes in blocks a call to ATTSYNC at the end should do the trick.
Thanks I'll give this a try. What is the command for this? I have never used a LISP before so still learning here 🙂
Instead of changing the Text/Mtext/whatever objects to all be the same Style, what we have done is to change all the Styles to use the same font [and in our case width factor]:
(defun C:ASA9 (/ cmde sty); = All Styles Arial font at 0.9 width factor
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 0)
(while (setq sty (cdr (assoc 2 (tblnext "style" (not sty)))))
(if (not (wcmatch sty "*|*")); not in an Xref
(command "_.style" sty "Arial" "" 0.9 "" "" "")
); if
); while
(setvar 'cmdecho cmde)
(princ)
)
There would still be all the Style names in the drawing, but they would all look the same.
EDIT: Also, it would handle the text in Dimensions, since it would change the font in all the Text Styles that the Dimensions use. The other suggestion that looks for the "StyleName" property would find that it's also a property available for Dimensions, but it will then try to impose a Text Style name on a Dimension, when that wants a Dimension Style name, of which there might not be one with the name used, unless you always go with STANDARD for everything. Even then, it will make the Dimension of Standard Dimension Style, which will not thereby change the text in it to Standard Text Style, if that Dimension Style uses something different.
And likewise for MultiLeaders, which also have a StyleName property but it's the name of the MultiLeader Style, not the Style of the Text elements in it.
@josie_higgins wrote:
Thanks I'll give this a try. What is the command for this? I have never used a LISP before so still learning here 🙂
The command to run it is 'foo'. You can change that to whatever you want (defun c:younameit
Hi thanks for this! ITs all pretty clever stuff.
I appreciate the help. Sorry just trying to get this straight in my head, what this would do, essentially, is just change all text, even in dims, leaders ect to font Arial at a 0.9 width factor. And keep all the text styles with the same names?
Also, I don't use the standard text style or dim style, I have created my own but this is what some of the blocks come in as.
Would the command would be ASA9?
Yes, it changes the font assigned in all Text Style definitions to the specified one [you can change it to whatever you want]. And yes, ASA9 is the command name [you can change that, too -- I would if you go with a different font or with something other than the 0.9 width factor].
The one situation in which some text could remain in a different font is if that is assigned as an override in Mtext or MultiLeader or Dimension text internal formatting. The Mtext editor has a place to clear internal formatting from selected content in those.
EDIT: Be aware that if you go for one of AutoCAD's .shx fonts instead of a .ttf font, there will be one more question to answer in the -STYLE command's prompt sequence, about vertical text. So you would need another "". If there's any doubt, run -STYLE [with the hyphen prefix] manually to be sure of what questions it asks and in what order, and which you would give Enter [double double-quotes] and which you need to give some other response.
I've used T.Willey's MergeTextStyles.lsp for many years to cleanup drawings by others. All the versions I used had a dialog box and with added features the 4.2 version works great! I believe you have to join theswamp.org to download it though.
Hi thanks for this, just letting you know it doesn't appear to work. But I really appreciate all the time and assistance.
@josie_higgins wrote:
...just letting you know it doesn't appear to work.....
What you want exists in full AutoCAD's CHECKSTANDARDS command, but you must create a DWS standards file from a master TEMPLATE file first: an yes, it is a slow process, the more your DWS contains the longer the task takes. So consider different DWS files for different specific needs (text styles in this case).
Josie, here is a lisp that changes Text, Mtext and Block (text) to 'Standard'.
Just do an AppLoad and pick it.
Cheers,
ECCAD