Code Red > AutoLISP (Vanilla / Visual)

Unusual symptom with acaddoc.lsp

(1/2) > >>

ribarm:
Greetings...

Recently while experimenting with ACAD, I met strange symptom... I created empty acaddoc.lsp and placed it in folder with some DWG files... Folder isn't in SFSP of both A2014 and A2018 CAD I have installed... Now when I open DWG from that folder using A2014, DWG opens instantly as acaddoc.lsp is empty and is not loading anything and has no alert message - this is all fine and OK... But now, I opened DWG with A2018 and now strange symptom... DWG is opened, but in the background my default acaddoc.lsp placed in SFSP is loaded with all tasks in it and pop-up-ing alert message as my last line in acaddoc.lsp I use frequently... So, what is wrong with all this... I want to load empty acaddoc.lsp placed in folder where my opening DWG resides... I need this as I want to start script opening bunch of DWGs in folder and performing actions on opened DWGs so that my alert message dialog box don't pop-up and script can QSAVE and CLOSE and proceed with next OPEN until everything is processed... I looked into system variables, but I can't find anything releted with this issue... Maybe I overlooked something, but I don't know... If you have some advice how to fix this strange thing I'll be grateful to you... Thanks for attention and reading... Best wishes in work and life, M.R.

tombu:
That's one of the security upgrades.  For years there were many acaddoc.lsp viruses that copied themselves into as many drawing folders as they could.  Open a drawing where one was would be a disaster.

Name it ribarmScript.lsp and load it from your regular acaddoc.lsp.  It will only load if it finds it so it should only load it with drawings in folders that have ribarmScript.lsp in it.

Untested, not sure if not being in a Trusted Folder will block it.

ribarm:
Thank you Tom for an answer... I was afraid that it's something unsolvable... Anyway, I tested my lisp I'll post here with A2014 and although when I open DWG from folder which has empty acaddoc.lsp it opens instantly like should, when I try my lisp which calls script command, it opens DWGS the same way I usually work with acaddoc.lsp from SFSP not working directory... So, I think I can't find usage for this lisp and I don't want to go other way VBA or something else... Too bad, sad but true...


--- Code: ---(defun mr nil
  (if (findfile (strcat (getvar 'tempprefix) "mr.scr")) (vl-file-delete (findfile (strcat (getvar 'tempprefix) "mr.scr"))))
  (setq mr nil)
  (princ)
)

(defun c:zoomextents ( / getfiles scroperation fullfilenames fn )

  (defun getfiles ( path / dirs files )
    (setq path (strcat path "\\"))
    (setq dirs (vl-directory-files path nil -1))
    (setq dirs (vl-remove "." dirs))
    (setq dirs (vl-remove ".." dirs))
    (setq files (vl-directory-files path "*.dwg" 1))
    (setq fullfilenames (append fullfilenames (mapcar '(lambda ( x ) (strcat path x)) files)))
    (mapcar '(lambda ( x ) (getfiles (strcat path x))) dirs)
    fullfilenames
  )

  (defun scroperation ( fullfilename / fn )
    (if (not (findfile (strcat (getvar 'tempprefix) "mr.scr")))
      (setq fn (open (strcat (getvar 'tempprefix) "mr.scr") "w"))
      (setq fn (open (strcat (getvar 'tempprefix) "mr.scr") "a"))
    )
    (write-line "open" fn)
    (write-line (strcat "\"" fullfilename "\"") fn)
    (write-line "(setq aclay (getvar 'ctab))" fn)
    (write-line "(foreach lay (layoutlist) (setvar 'ctab lay) (vl-cmdf \"_.ZOOM\" \"_E\"))" fn)
    (write-line "(setvar 'ctab aclay)" fn)
    (write-line "(vl-cmdf \"_.ZOOM\" \"_E\")" fn)
    (write-line "(setq aclay nil)" fn)
    (write-line "qsave" fn)
    (write-line "close" fn)
    (close fn)
    (princ)
  )

  (alert "After execution of routine, type (mr) to finish routine task properly")
  (setq fullfilenames (getfiles (vl-filename-directory (getfiled "Select main directory other than currently working DWG folder" "" "dwg" 4))))
  (setq fn (open (strcat (car (fnsplitl (car fullfilenames))) "acaddoc.lsp") "w"))
  (write-line "" fn)
  (close fn)
  (foreach file fullfilenames
    (scroperation file)
  )
  (vl-cmdf "_.script" (strcat (getvar 'tempprefix) "mr.scr"))
  (vl-file-delete (strcat (car (fnsplitl (car fullfilenames))) "acaddoc.lsp"))
  (princ)
)

--- End code ---

Thanks anyway, M.R.

roy_043:
SECURELOAD?

ribarm:
No, I have SECURELOAD=0... I also tried LEGACYCODESEARCH, but also without success...

:(

Navigation

[0] Message Index

[#] Next page

Go to full version