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

deleting a file

5 REPLIES 5
Reply
Message 1 of 6
Hidden_Brain
295 Views, 5 Replies

deleting a file

can someone help me out with this one? trying to delete a file every time CAD is fired up and/or a new drawing is opened. i cannot make it work so far. planning to incorporate it into acaddoc  lsp file.

 

(defun deletestupidfile()
(vl-load-com)
(setq myname (getvar "loginname"))
(if (= (getenv "PROCESSOR_ARCHITECTURE") "AMD64")
(progn
(vl-file-delete (strcat "C:\\Users\\" myname" \\AppData\\Roaming\\Autodesk\\C3D 2011\\enu\\Support\\test.xlsx"))
)
(progn
(vl-file-delete (strcat "C:\\Users\\" myname" \\AppData\\Roaming\\Autodesk\\C3D 2011\\enu\\Support\\test.xlsx"))
(princ)
)
)
)

5 REPLIES 5
Message 2 of 6
Jeff_M
in reply to: Hidden_Brain

You have a space where it doesn't belong in 2 places.... 

.... " myname" \\AppData.....

should be:
.... " myname "\\AppData.....

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 6
Hidden_Brain
in reply to: Jeff_M

thanks for the reply Jeff, i still cannot make it to work. if you do not mind, can you please take another peek:

 

(defun deletestupidfile(event parameter)
(vl-load-com)
(setq myname (getvar "loginname"))
(if (= (getenv "PROCESSOR_ARCHITECTURE") "AMD64")
(progn
(vl-file-delete (strcat "C:\\Users\\" myname "\\AppData\\Roaming\\Autodesk\\C3D 2011\\enu\\Support\\test.xlsx"))
)
(progn
(vl-file-delete (strcat "C:\\Documents and Settings\\" myname "\\Application Data\\Roaming\\Autodesk\\C3D 2011\\enu\

\Support\\test.xlsx"))
(princ)
)
)
)

 

 

it should run automatically (added to acaddocXXXX.lsp), every time i open a drawing or fire up CAD, and delete that test.xlsx file. does not seem to do it currently.

 

Message 4 of 6
Lee_Mac
in reply to: Hidden_Brain

Looking at the required arguments for the function, are you intending to run this as a callback function of a reactor? Otherwise, you will need to supply the function with the arguments for 'event' and 'parameter'.

 

You should only modify either the ACADDOC.lsp or ACAD.lsp (create these if they don't exist in the support path), the other files are reserved for AutoCAD.

 

Read this:

http://docs.autodesk.com/ACD/2011/ENU/filesACG/WS73099cc142f4875513fb5cd10c4aa30d6b-7f72.htm

 

Perhaps consider the following function:

 

(defun deletestupidfile nil
    (if (vl-string-search "64" (getenv 'PROCESSOR_ARCHITECTURE))
        (vl-file-delete (strcat "C:\\Users\\" (getvar 'LOGINNAME) "\\AppData\\Roaming\\Autodesk\\C3D 2011\\enu\\Support\\test.xlsx"))
        (vl-file-delete (strcat "C:\\Documents and Settings\\" (getvar 'LOGINNAME) "\\Application Data\\Roaming\\Autodesk\\C3D 2011\\enu\\Support\\test.xlsx"))
    )
    (princ)
)
(vl-load-com)
(deletestupidfile)

 

Copy the above into your ACADDOC.lsp.

 

Message 5 of 6
Hidden_Brain
in reply to: Lee_Mac

still cannot make it work! this is now driving me nuts. i copied it to acaddoc lsp, the file test.xlsx does nto get deleted! now what am i doing wrong??

 

*Edited:

nevermind, i noticed shortly after it was bailing as the PROCESSOR_ARCHITECTURE did not have quotes ("") around it. thanks for the the help, much appreciate.

Message 6 of 6
Lee_Mac
in reply to: Hidden_Brain


@youngEIT wrote:
 

*Edited:

nevermind, i noticed shortly after it was bailing as the PROCESSOR_ARCHITECTURE did not have quotes ("") around it.


Not sure how I missed that!  Smiley Sad

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

Post to forums  

Autodesk Design & Make Report

”Boost