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

Getting acad.lsp to run before drawing template loaded

4 REPLIES 4
Reply
Message 1 of 5
nbawden
312 Views, 4 Replies

Getting acad.lsp to run before drawing template loaded

Using information provided in this forum I have created an acad.lsp to add a Trusted Path and add a Support File Search Path.

 

This appears to work correctly - well sort of.

 

It appears that the drawing template is loaded before the acad.lsp is run. The issue with this is that the template relies on the additional Support File Search Path being added in order for certain SHX files to be loaded correctly with the template. How can I get the following acad.lsp code to run before the drawing template is opened? (I know this is only an issue for the 1st time this is run and won;t affect future sessions - I just want it to work from 1st go)

 

(setvar "ACADLSPASDOC" 0)

;Set trusted path
(if (>= (getvar "ACADVER") "20.0")
(setvar "trustedpaths" (strcat (getvar "trustedpaths")
";C:\\Civil3D\\Tomkinson Civil3D Support Files"
)))


;; Add Support File Search Paths at 'n'  -  Lee Mac
;; Adds a list of Support File Search Paths, excluding duplicates and invalid paths.
;; lst - [lst] list of paths to add, e.g. '("C:\\Folder1" "C:\\Folder2" ... )
;; idx - [int] [optional] zero-based index at which to add new paths
;; Returns: [str] "ACAD" Environment String following modification


(defun LM:sfsp+n ( lst idx / add str )

    (defun add ( str new idx / pos )
        (if (< 0 idx)
            (if (setq pos (vl-string-position 59 str))
                (strcat (substr str 1 (1+ pos)) (add (substr str (+ pos 2)) new (1- idx)))
                (strcat ";" new)
            )
            (strcat new str ";")
        )
    )

    (setenv "ACAD"
        (add (setq str (vl-string-right-trim ";" (getenv "ACAD")))
            (apply 'strcat
                (mapcar '(lambda ( x ) (strcat x ";"))
                    (vl-remove-if
                       '(lambda ( x )
                            (or (vl-string-search (strcase x) (strcase str))
                                (not (findfile x))
                            )
                        )
                        (mapcar
                           '(lambda ( x )
                                (vl-string-right-trim "\\" (vl-string-translate "/" "\\" x))
                            )
                            lst
                        )
                    )
                )
            )
            idx
        )
    )
)

;lisp warning
(alert "sfsp function defined!")

(LM:sfsp+n '("C:\\Civil3D\\Tomkinson Civil3D Support Files") 0)

;lisp warning
(alert "sfsp function applied!")

; Loads Tomkinson Group acad.lsp equivalent file from C:\Civil3D\Tomkinson Civil3D Support Files)
(load "C:\\Civil3D\\Tomkinson Civil3D Support Files\\Tomk-acad.lsp")

;lisp sign-off
(alert (strcat "!!! acad.lsp completed " (getvar "loginname")  " !!!"))

 

4 REPLIES 4
Message 2 of 5
dbroad
in reply to: nbawden

If your approach worked, it would indicate that the security improvements in AutoCAD were worthless.  You might as well set the secureload to 0 if a lisp program can change the trustedpaths variable.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 5
nbawden
in reply to: dbroad

Its all a bit over my head. Our reseller is strongly sugegsting we move over to the new .bundle solution instead. From what I have read this has its own security holes as well!

Message 4 of 5
dbroad
in reply to: nbawden

Adding a trusted path is something that needs to be done only once. It certainly does not need to be added each time the application is opened or each time a drawing is opened.  That would create unnecessary overhead.  For your package, just set up the profiles once manually and you're done.

Architect, Registered NC, VA, SC, & GA.
Message 5 of 5
nbawden
in reply to: dbroad

Thanks for your thoughts again - we have to do it this way for reasons of deployment and how our office functions. As long as the ew tab screen launches instead of a template based blank drawing then no issues - as this is the default then all is good. I'm happy with the solution I have come up with - time impact is not detectable.

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

Post to forums  

”Boost