Adding to Options:Files tab without changing whole Profile

Discussion in 'AutoCAD' started by James Wedding, Jul 29, 2004.

  1. I'd like to make some changes to my users support paths without changing the
    entire Profile out. Any suggestions?

    --
    James Wedding, P.E.
    IT Manager
    Jones & Boyd, Inc.
    Dallas, TX
    XP/1 on P4-3.4/1G
    LDT2004&5+C3D
    http://au.autodesk.com
    Sign up now for AU2004!
     
    James Wedding, Jul 29, 2004
    #1
  2. Something to play with:
    (vla-get-supportpath (vla-get-files (vla-get-preferences
    (vlax-get-acad-object))))

    (vla-put-supportpath (vla-get-files (vla-get-preferences
    (vlax-get-acad-object))) paths)
    --
    Best Regards, Jimmy Bergmark
    CAD and Database Developer Manager at www.pharmadule-emtunga.com
    Take a look at
    JTB FlexReport (FLEXlm report tool) - www.jtbworld.com/jtbflexreport
    SmartPurger (Purges automatically) - www.jtbworld.com/?/smartpurger.htm
    or download some freeware at www.jtbworld.com
    More on AutoCAD 2005;
    www.jtbworld.com/autocad2005.htm
     
    Jimmy Bergmark, Jul 29, 2004
    #2
  3. James Wedding

    John Uhden Guest

    Hi, James.
    Here are a couple of functions I finally got around to:
    ;;------------------------------------------
    ;; Function created (04-11-03) to add a Path
    ;; to the AutoCAD SupportPath:
    ;; Added Pos (07-22-04) which allows you to change the position of
    ;; an existing path as well.
    ;; John F. Uhden, Cadlantic
    (defun @AddPath (Path Pos / Prefs Files Old New i)
    (and
    (vl-load-com)
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (= (type Path) 'STR)
    (vl-file-directory-p Path)
    (setq Prefs (vlax-get *acad* 'Preferences))
    (setq Files (vlax-get Prefs 'Files))
    (setq Old (vlax-get Files 'SupportPath))
    (setq Old (@cv_Str2List Old ";"))
    (or
    (not (setq i (vl-position (strcase Path)(mapcar 'strcase Old))))
    (setq Old (vl-remove (nth i Old) Old))
    )
    (setq i 0)
    (foreach item Old
    (if (= Pos i)
    (setq New (cons Path New))
    )
    (setq New (cons item New)
    i (1+ i)
    )
    )
    (or
    (vl-position Path New)
    (setq New (cons Path New))
    )
    (setq New (reverse New))
    (setq New (apply 'strcat (mapcar (function (lambda (x)(strcat x ";")))
    New)))
    (setq New (vl-string-trim ";" New))
    (not (vlax-put Files 'SupportPath New))
    (setq New (vlax-get Files 'SupportPath))
    )
    New
    )

    Examples:
    ;; Add my own path to the end of the list:
    (@AddPath "C:\\Cadlantic\\2004\\Support" 99)
    ;; (07-22-04) moves the traditional Support directory to the top of the list:
    (@AddPath (strcat (vl-filename-directory (findfile "acad.exe")) "\\Support") 0)

    ;;---------------------------------------------
    ;; Function created (07-22-04) to change a Preferences->Files->Path
    ;; John F. Uhden, Cadlantic
    (defun @ChangePath (File Path / Prefs Files Old New)
    (and
    (vl-load-com)
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (= (type Path) 'STR)
    (= (type File) 'STR)
    (or (vl-file-directory-p Path)(findfile Path))
    (setq Prefs (vlax-get *acad* 'Preferences))
    (setq Files (vlax-get Prefs 'Files))
    (not
    (vl-catch-all-error-p
    (setq Old
    (vl-catch-all-apply
    'vlax-get
    (list Files (read File))
    )
    )
    )
    )
    (/= (strcase Old)(strcase Path))
    (not (vlax-put Files (read File) Path))
    (setq New (vlax-get Files (read File)))
    )
    New
    )

    Example:
    ;; Printer Configuration File Search Path (.PC3)
    (@ChangePath "PrinterConfigPath" (strcat (vl-filename-directory (findfile
    "acad.exe")) "\\Plotters"))

    You put 'em in your acaddoc.lsp and they work just fine.
     
    John Uhden, Jul 30, 2004
    #3
  4. Good stuff. (I know your message was for the other James, anyway...)
    I like the or in (or *acad* (setq *acad* (vlax-get-acad-object))) statement, too slick, I will start using that format
    for initializing vars.
    Just thought I'd mention it.

    "John Uhden" <>
    |>Hi, James.
    |>Here are a couple of functions I finally got around to:
    |>;;------------------------------------------
    |>;; Function created (04-11-03) to add a Path
    |>;; to the AutoCAD SupportPath:
    |>;; Added Pos (07-22-04) which allows you to change the position of
    |>;; an existing path as well.
    |>;; John F. Uhden, Cadlantic
    |>(defun @AddPath (Path Pos / Prefs Files Old New i)
    |> (and
    |> (vl-load-com)
    |> (or *acad* (setq *acad* (vlax-get-acad-object)))
    |> (= (type Path) 'STR)
    |> (vl-file-directory-p Path)
    |> (setq Prefs (vlax-get *acad* 'Preferences))
    |> (setq Files (vlax-get Prefs 'Files))
    |> (setq Old (vlax-get Files 'SupportPath))
    |> (setq Old (@cv_Str2List Old ";"))
    |> (or
    |> (not (setq i (vl-position (strcase Path)(mapcar 'strcase Old))))
    |> (setq Old (vl-remove (nth i Old) Old))
    |> )
    |> (setq i 0)
    |> (foreach item Old
    |> (if (= Pos i)
    |> (setq New (cons Path New))
    |> )
    |> (setq New (cons item New)
    |> i (1+ i)
    |> )
    |> )
    |> (or
    |> (vl-position Path New)
    |> (setq New (cons Path New))
    |> )
    |> (setq New (reverse New))
    |> (setq New (apply 'strcat (mapcar (function (lambda (x)(strcat x ";")))
    |>New)))
    |> (setq New (vl-string-trim ";" New))
    |> (not (vlax-put Files 'SupportPath New))
    |> (setq New (vlax-get Files 'SupportPath))
    |> )
    |> New
    |>)
    |>
    |>Examples:
    |>;; Add my own path to the end of the list:
    |>(@AddPath "C:\\Cadlantic\\2004\\Support" 99)
    |>;; (07-22-04) moves the traditional Support directory to the top of the list:
    |>(@AddPath (strcat (vl-filename-directory (findfile "acad.exe")) "\\Support") 0)
    |>
    |>;;---------------------------------------------
    |>;; Function created (07-22-04) to change a Preferences->Files->Path
    |>;; John F. Uhden, Cadlantic
    |>(defun @ChangePath (File Path / Prefs Files Old New)
    |> (and
    |> (vl-load-com)
    |> (or *acad* (setq *acad* (vlax-get-acad-object)))
    |> (= (type Path) 'STR)
    |> (= (type File) 'STR)
    |> (or (vl-file-directory-p Path)(findfile Path))
    |> (setq Prefs (vlax-get *acad* 'Preferences))
    |> (setq Files (vlax-get Prefs 'Files))
    |> (not
    |> (vl-catch-all-error-p
    |> (setq Old
    |> (vl-catch-all-apply
    |> 'vlax-get
    |> (list Files (read File))
    |> )
    |> )
    |> )
    |> )
    |> (/= (strcase Old)(strcase Path))
    |> (not (vlax-put Files (read File) Path))
    |> (setq New (vlax-get Files (read File)))
    |> )
    |> New
    |>)
    |>
    |>Example:
    |>;; Printer Configuration File Search Path (.PC3)
    |>(@ChangePath "PrinterConfigPath" (strcat (vl-filename-directory (findfile
    |>"acad.exe")) "\\Plotters"))
    |>
    |>You put 'em in your acaddoc.lsp and they work just fine.

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jul 30, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.