Command "_style" in Lisp Routine Not Working on Startup

Command "_style" in Lisp Routine Not Working on Startup

Exnovo
Participant Participant
1,508 Views
7 Replies
Message 1 of 8

Command "_style" in Lisp Routine Not Working on Startup

Exnovo
Participant
Participant

Hello,

 

Hoping someone can help me with this lisp command I cannot get to work on startup.

 

My Issue

I have a ton of drawings that contain a text style with a missing font. By missing I mean I open the Text Style editor and when I click on the text style, it doesn't show a font at all. Also any text on the text style I double click to edit appear blank. If I manually change the text style font to something else like standard, problem solved.

 

My Solution

I created a batch file that that opens all the drawings in a folder and runs a script each time.

 

FOR %%f in (C:\"Temp"\"Convert"\*.dwg) do start /wait C:\"Program Files"\"Autodesk"\"AutoCAD 2016"\acad.exe "%%f" /b "C:\Change_Font.scr"

The script then loads the lisp.

 

(load "U:\\Change_Font.lsp")

And the script then runs the "_style" command to change the text style font to standard.shx.

 

(defun C:TextStyleFontChange ()
    (command "_style" "Style-WORKING" "standard.shx" "" "" "" "" "" "")
)

If I load into a single drawing, load the lisp via appload, and then type in the function name "TEXTSTYLEFONTCHANGE" the text style font will change to the standard.shx. But if I run it through the Batch>Script>Lisp process, it does nothing.

 

Am I missing a command in there? Do I need to also run a command after similar to how I had to type in the function name to run it manually? Any help would be very much appreciated as there are tens of thousands of drawings that this needs to be ran on.

 

Thanks

 

0 Likes
Accepted solutions (1)
1,509 Views
7 Replies
Replies (7)
Message 2 of 8

john.uhden
Mentor
Mentor
Accepted solution

My first, and only, reaction is that your code is loading the function, but it is not running it.

If "Change_Font.lsp" contains "

(defun C:TextStyleFontChange () ...)

 then change Change_Font.lsp to just...

(command "_style" "Style-WORKING" "standard.shx" "" "" "" "" "" "")

Presuming you are using acaddoc.lsp, then skip the loading and just include

(command "_style" "Style-WORKING" "standard.shx" "" "" "" "" "" "")
in your acaddoc.lsp 

@Kent1Cooper recently demonstrated (at least to his satisfaction) that S::STARTUP is not required.  But if  @dbroad (Doug Broad) disagrees with Kent, then I would follow Doug's advice.  Doug has been around here so long that even Tony Tanzillo looks up to him (yeah, sure).  If you don't know of Tony, then all the better for you.  But don't listen to me 'cause I'm just a "pea brain."

John F. Uhden

Message 3 of 8

dbroad
Mentor
Mentor

@john.uhden

  1. Tony T. would still view me as an amateur and he would probably still be correct.
  2. I would hate to be in competition with Kent but I continue to use s::startup in my routines.

 

@Exnovo

  1. I'm not sure why I would even worry about this. Fontalt and Fontmap should be doing the job of providing you with the fonts you need without intervention.
  2. In general, it can be a very bad idea to batch process more than a current project folder.  For me, it messes up all the file stamp information.
  3. If you are doing batch processing, avoid using batch file techniques.  Use scriptpro, which is built into AutoCAD and can take advantage of the core console features. That said, if you really want to batch AutoCAD with a batch file, you should set SDI to 1.
  4. Not everything that works in AutoCAD when fully loaded works in the core console.
  5. "Style-WORKING" seems like a very presumptive and unuseful and undescriptive style name.  I've personally never heard of standard.shx.  If you want to use a standard font, use a standard style with a widely available font, such as simplex.shx.
  6. Using shx fonts is passé in my opinion.  They create all sorts of issues with PDF files.  Use TTF fonts that create searchable pdf files.

For the past 3 years, I have used the following after opening a drawing that appeared to contain older font specifications.

;;modernize fonts - switch to universally available san-serif TTF font.
;;D. C. Broad, Jr.  3/25/2015
(defun c:modernize (/ doc)
 (setq doc (vla-get-activedocument
	     (vlax-get-acad-object)
	     )
       )
  (vlax-for n (vla-get-textstyles doc)
    (vla-setfont n "arial" :vlax-false :vlax-false 0 34)
    (vla-put-width n 1.0)
    )
  (princ)
  )

;alias
(defun c:mo ()(c:modernize))

 

 

Architect, Registered NC, VA, SC, & GA.
Message 4 of 8

Exnovo
Participant
Participant

Morning John, that was it. All I had to do was remove the function portion and it worked perfect. I am new to using lisp so this is a learning experience for me so thank you for replying!

0 Likes
Message 5 of 8

Exnovo
Participant
Participant

Hi dbroad, unfortunately I cannot change any aspect of the drawing and was only asked to help alleviate this one particular problem and I had to do so by matching the font to what I can visually see.

 

In regards to batch processing, this is a process already being done on the drawings so adding this routine to it will not change the outcome other than fixing the one issue. Thanks for posting.

0 Likes
Message 6 of 8

john.uhden
Mentor
Mentor

IMHO, to hello with PDF files.  DWFs are much more valuable and about a third of the size.

John F. Uhden

0 Likes
Message 7 of 8

dbroad
Mentor
Mentor

In theory, I agree with you.  I just couldn't convince my clients to use dwf files.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 8 of 8

john.uhden
Mentor
Mentor

@dbroad wrote "In theory, I agree with you [about DWFs vs PDFs].  I just couldn't convince my clients to use dwf files."

 

That IS the problem.  Maybe you should get some clients. :]

John F. Uhden

0 Likes