Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create Auto/Visual LISP to combine text styles

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
josie_higgins
547 Views, 13 Replies

Create Auto/Visual LISP to combine text styles

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!

13 REPLIES 13
Message 2 of 14
Simon_Weel
in reply to: josie_higgins

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? 

Message 3 of 14

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? 

Message 4 of 14
paullimapa
in reply to: josie_higgins

If the different Text Styles are all used within various Blocks then you cannot merge them.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 14
ronjonp
in reply to: josie_higgins

@josie_higgins 

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.

 

Message 6 of 14
josie_higgins
in reply to: ronjonp

Thanks I'll give this a try. What is the command for this? I have never used a LISP before so still learning here 🙂 

Message 7 of 14
Kent1Cooper
in reply to: josie_higgins

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.

Kent Cooper, AIA
Message 8 of 14
ronjonp
in reply to: josie_higgins


@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

Message 9 of 14
josie_higgins
in reply to: Kent1Cooper

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?

 

 

Message 10 of 14
Kent1Cooper
in reply to: josie_higgins

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.

Kent Cooper, AIA
Message 11 of 14
TomBeauford
in reply to: josie_higgins

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.

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
Message 12 of 14
josie_higgins
in reply to: ronjonp

Hi thanks for this, just letting you know it doesn't appear to work. But I really appreciate all the time and assistance. 

Message 13 of 14
pendean
in reply to: josie_higgins


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

Message 14 of 14
ec-cad
in reply to: josie_higgins

Josie, here is a lisp that changes Text, Mtext and Block (text) to 'Standard'.

Just do an AppLoad and pick it.

Cheers,

ECCAD

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost