Author Topic: Unusual symptom with acaddoc.lsp  (Read 2532 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Unusual symptom with acaddoc.lsp
« on: February 15, 2019, 04:26:48 PM »
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.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Unusual symptom with acaddoc.lsp
« Reply #1 on: February 15, 2019, 05:05:49 PM »
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.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Unusual symptom with acaddoc.lsp
« Reply #2 on: February 16, 2019, 03:42:15 AM »
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: [Select]
(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)
)

Thanks anyway, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Unusual symptom with acaddoc.lsp
« Reply #3 on: February 16, 2019, 11:18:57 AM »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Unusual symptom with acaddoc.lsp
« Reply #4 on: February 16, 2019, 03:28:32 PM »
No, I have SECURELOAD=0... I also tried LEGACYCODESEARCH, but also without success...

:(
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Unusual symptom with acaddoc.lsp
« Reply #5 on: February 22, 2019, 07:35:11 AM »
This could be done by using a seperate profile that had a blank acaddoc.lsp & acad.lsp in a separate folder placed at the top of the SFSP and list of Trusted Locations.  You would have to switch to that profile before opening drawings you don't want to use your normal acaddoc.lsp.

Good for opening forum posted drawings you don't want modified when you open them.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ChrisCarlson

  • Guest
Re: Unusual symptom with acaddoc.lsp
« Reply #6 on: February 22, 2019, 08:05:43 AM »
Sometimes it seems a fresh install is the only way to cure these random problems, my question would be why are you modifying the acaddoc.lsp file?

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Unusual symptom with acaddoc.lsp
« Reply #7 on: February 22, 2019, 11:44:49 AM »
Sometimes it seems a fresh install is the only way to cure these random problems, my question would be why are you modifying the acaddoc.lsp file?

I am not modifying acaddoc.lsp - I want to use blank one... Why - because my acaddoc.lsp has bunch of routines that are loading and this takes time and as I stated it has alert line which causes interaction from user failing to perform script operations like should - without interactions and as fast as possible - see my lisp I posted - now it has no purpose at all, but in fact it should do what's written - create script with OPEN dwg - zooming extends all layouts, QSAVE, CLOSE dwg and repeat until all script is processed - script should collect all dwg files in folder you specify by routine... Because script file can't be deleted while script is running and after it finishes process at the end of routine, you have to manually type (mr) sub which is also loaded to remove mr.scr from temp folder (but this is not a problem - problem is CAD with buggy OPEN within script operations - it don't want to use blank acaddoc.lsp which is placed in the same folder as dwg files... And by the way, I don't want new profile and switching to it just because of this one lisp - I thought that it should work fine as it is written (lisp I posted)...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Unusual symptom with acaddoc.lsp
« Reply #8 on: March 22, 2019, 06:50:49 AM »
I just wanted to say that I finally corrected my (c:zoomextents) routine... It works as expected - don't forget that after usage you type (mr) at command prompt to restore temporarily backup acaddoc.lsp... So here is it :

Code: [Select]
(defun mr nil
  (vl-file-copy (strcat (car (fnsplitl adfn)) "oldacaddoc.txt") adfn)
  (vl-file-delete (strcat (car (fnsplitl adfn)) "oldacaddoc.txt"))
  (vl-file-delete scrfn)
  (setq adfn nil scrfn 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 script operation complete type (mr) at command prompt to restore erased acaddoc.lsp file from your support folder...")
  (setq adfn (findfile "acaddoc.lsp"))
  (vl-file-copy adfn (strcat (car (fnsplitl adfn)) "oldacaddoc.txt"))
  (vl-file-delete adfn)
  (setq fullfilenames (getfiles (vl-filename-directory (getfiled "Select main directory other than currently working DWG folder" "" "dwg" 4))))
  (foreach filen fullfilenames
    (scroperation filen)
  )
  (vl-cmdf "_.script" (setq scrfn (strcat (getvar 'tempprefix) "mr.scr")))
  (princ)
)

Regards, M.R.
(thanks to everyone trying to help me...)
« Last Edit: April 08, 2019, 09:03:19 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: Unusual symptom with acaddoc.lsp
« Reply #9 on: March 25, 2019, 07:13:05 AM »
You can run a script as part of the Autocad icon settings may be a way. It calls your lsp. We don’t use acaddoc.lsp. What happens if you add your lisp as name only if you can to the Appload history.
A man who never made a mistake never made anything