Lisp to set the fonts search path

Lisp to set the fonts search path

jbear0000
Collaborator Collaborator
1,127 Views
13 Replies
Message 1 of 14

Lisp to set the fonts search path

jbear0000
Collaborator
Collaborator

I have the following code that was created by Bigal and I modified to meet my needs, but I can't figure out how to set the fonts folder. I want to remove this: C:\Program Files\Autodesk\AutoCAD 2016\Fonts and replace it with Y:\Library\CAD Support Files\Fonts

The original code is here:
http://www.cadtutor.net/forum/archive/index.php/t-77358.html?s=7273bed22b69b0b962a29ed2e9740df1

This is what I have:

 

; resets the paths usefull for update versions of Autocad
; by BIGAL 2011
; This sets a reference to the install path of your product
; the gets are their for info maybe other use
; use this to find other settings 
;(vlax-dump-object (vla-get-files (vla-get-preferences (vlax-get-Acad-object))) T)

(vl-load-com)
; make temp directory
(vl-mkdir "c:\\Autocad Autosaves")
(setq *files* (vla-get-files (vla-get-preferences (vlax-get-Acad-object))))

; Autosave Location
(vla-put-AutoSavepath *files* "C:\\Autocad Autosaves")

; Printers Configuration Search Path
(vla-put-PrinterConfigPath *files* "Y:\\Library\\Plotters")

; Printer Description File Search Path
(vla-put-PrinterDescPath *files* "Y:\\Library\\Plotters")

; Plot Style Table Search Path
(vla-put-PrinterStyleSheetPath *files* "Y:\\Library\\CAD Support Files\\Plot styles")

; Drawing Template File Location
(vla-put-TemplateDwgPath *files* "Y:\\Library\\CAD Support Files\\Template Files")

; Default Template File Name for QNEW
(vla-put-QnewTemplateFile *files* "")

;make new support paths exist + new
(setq paths (vla-get-SupportPath *files*))

(setq coggpaths 
Y:\\Library\\CAD Support Files\\Fonts;
)

; Plot Log File Path
(vla-put-PlotLogFilePath *files* "C:\\Autocad Autosaves")
; Log File Path
(vla-put-LogFilePath *files* "C:\\Autocad Autosaves")

; end use of *files*
(vlax-release-object *files*)
; exit quitely
(princ "All Done") 

 

0 Likes
1,128 Views
13 Replies
Replies (13)
Message 2 of 14

hmsilva
Mentor
Mentor

@jbear0000 wrote:

I have the following code that was created by Bigal and I modified to meet my needs, but I can't figure out how to set the fonts folder. I want to remove this: C:\Program Files\Autodesk\AutoCAD 2016\Fonts and replace it with Y:\Library\CAD Support Files\Fonts

The original code is here:
http://www.cadtutor.net/forum/archive/index.php/t-77358.html?s=7273bed22b69b0b962a29ed2e9740df1

This is what I have:

 

 ...


Hi jbear0000,

we should not remove the default SupportPath.

BIGAL's approach, is correct, adding the new search paths first, AutoCAD will find the new directories, and if there exist some network problem will find the default ones...

 

So, try to put back in the code this two code lines

 

(setq newpath (strcat coggpaths paths))
(vla-put-SupportPath *files* newpath)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 14

jbear0000
Collaborator
Collaborator

Thank you hmsilva, I didn't realize that those lines of code were part of that section for the support files.

 

What is I wanted to have it look in more than one folder for plot styles? How could I make it do that?

0 Likes
Message 4 of 14

hmsilva
Mentor
Mentor

@jbear0000 wrote:

Thank you hmsilva, I didn't realize that those lines of code were part of that section for the support files.

 

What is I wanted to have it look in more than one folder for plot styles? How could I make it do that?


You're welcome, jbear0000

 

To add a new plot style folder, maybe something to do the trick:

 

(setq PSSP (vla-get-printerstylesheetpath *files*))
(vla-put-PrinterStyleSheetPath *files* (strcat "Y:\\Library\\CAD Support Files\\Plot styles;" PSSP))

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 5 of 14

jbear0000
Collaborator
Collaborator

That works, but I am adding this code to a lisp that will run every time cad starts and it causes duplicate paths. How can I have it just delete the paths for the plot styles and then just replace them with the ones listed in the coding?

0 Likes
Message 6 of 14

hmsilva
Mentor
Mentor
(setq PSSP (vla-get-printerstylesheetpath *files*))
(if (not (wcmatch PSSP "*Y:\\Library\\CAD Support Files\\Plot styles*"))
  (vla-put-PrinterStyleSheetPath *files* (strcat "Y:\\Library\\CAD Support Files\\Plot styles;" PSSP))
)

 

Henrique

EESignature

Message 7 of 14

jbear0000
Collaborator
Collaborator

Thanks again, I was able to get that to do exactly what I wanted.

0 Likes
Message 8 of 14

hmsilva
Mentor
Mentor

@jbear0000 wrote:

Thanks again, I was able to get that to do exactly what I wanted.


You're welcome, jbear0000

Henrique

EESignature

0 Likes
Message 9 of 14

jbear0000
Collaborator
Collaborator

How would I get it to be flexible for any username to replace

C:\Users\%username%\AppData\Roaming\Autodesk\C3D 2016\enu\plotters\Plot Styles

with

Y:\Library\CAD Support Files\Archive\Plot styles?

 

This is what I have:

(setq PSSP (vla-get-printerstylesheetpath *files*))
(if (wcmatch PSSP "*C:\\Users\\%username%\\AppData\\Roaming\\Autodesk\\C3D 2016\\enu\\plotters\\Plot Styles*")
  (vla-put-PrinterStyleSheetPath *files* (strcat "Y:\\Library\\CAD Support Files\Archive\\Plot styles;" PSSP))
)

But apparently %username% isn't the right way to go about it. I found (getenv "username"), but am not sure how to use it in something like this.

0 Likes
Message 10 of 14

hmsilva
Mentor
Mentor
(wcmatch PSSP (strcat "*C:\\Users\\" (getenv "username") "\\AppData\\Roaming\\Autodesk\\C3D 2016\\enu\\plotters\\Plot Styles*"))

 

Henrique

EESignature

0 Likes
Message 11 of 14

jbear0000
Collaborator
Collaborator

Thanks again, that works to add the new folder, but how can I get it to then remove the C:\\Users\\" (getenv "username") "\\AppData\\Roaming\\Autodesk\\C3D 2016\\enu\\plotters\\Plot Styles folder?

0 Likes
Message 12 of 14

hmsilva
Mentor
Mentor
(if (wcmatch PSSP (strcat "*C:\\Users\\" (getenv "username") "\\AppData\\Roaming\\Autodesk\\C3D 2016\\enu\\plotters\\Plot Styles*"))
  (vla-put-PrinterStyleSheetPath *files* "Y:\\Library\\CAD Support Files\Archive\\Plot styles")
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 13 of 14

jbear0000
Collaborator
Collaborator

That did it, thanks again for all of your help.

0 Likes
Message 14 of 14

hmsilva
Mentor
Mentor

@jbear0000 wrote:

That did it, thanks again for all of your help.


You're welcome, jbear0000
Glad I could help

Henrique

EESignature

0 Likes