I tried it and it still doesn't work. The variable is already passed as a string in the beginning.
Hi Kent,
I tried it and it still doesn't work for me too.
There is another solution?
Thanks in advance.
@antistar wrote:....
I tried it and it still doesn't work for me too.
....
I can't imagine why it would not work, though I haven't loaded it up and tried it. If (strcat folderName "\\batchJob.scr") works in the (open) function to start making the Script, and in the (command) function to run the Script, then it must be a valid file designator, and should work in (vl-file-delete) to remove it, too. I suggest you carefully comb through the code to make sure all function and file and variable names are spelled exactly the same way, etc., but I have no other ideas. Does "it doesn't work" simply mean that the file is not deleted, or is there more to it, e.g. any error message?
Hi Kent, thanks for reply.
The routine works, but the file is not deleted and not show any error message.
Would not it be something related to the format of the "folderName" variable?
Check your file permissions. It could be that the file is created without read/write/create/delete permissions. Find the file on your HDD select, right-click, properties near the bottom of the dialog you should see read only unchecked and not greyed out. Also, it may be that you'll have to delete it in a seperate function after releasing the file from the original.
>(command ".script" (strcat folderName "\\batchJob.scr"))
>(vl-file-delete folderName "\\batchJob.scr")
Try to put:
(command ".script" (strcat folderName "\\batchJob.scr"))
(alert "End Script")
and you never see "End Script", I think that anything made after the launch of the script will not be executed.
The command vl-filename-mktemp doesn't work. After running the script batchJob.scr, the file is still there. I am beginning to wonder if AutoCAD doesn't continue running the lsp file after running the script file.
This is what I did, but there may be other ways.
(setq *fname* (vl-filename-mktemp "batchJob.scr") scrFile (open (strcat folderName "\\" *fname*) "w") )
And to remove the file:
(vl-file-delete *fname*)
u will have to use VBA... for lisp you lose focus.
if you do not want to use VBA then you can create a variable, put it on the blackboard (vl-bb-set
then in your mnl or acaddoc.lsp file check for this variable and accordingly do whatever u need.
HTH
Maybe you can delete it while is running, try to delete a last step in the script, but I dubt...
Sorry for my english.
Matc'A ... good idee, add the following line just before (close scrFile)
(write-line "(vl-file-delete (strcat folderName (chr 34) \\batchJob.scr (chr 34) ))" scrfile)
and givi it a shot
m
From the time that my file finished running I had to include a short delay before deleting the file.
(command "delay" "3000")
Beyond that I don't know why mine is working and you are still looking for a solution. Sorry I could not be of more help.
@AlessiMarc'Antonio wrote:>(command ".script" (strcat folderName "\\batchJob.scr"))
>(vl-file-delete folderName "\\batchJob.scr")
Try to put:
(command ".script" (strcat folderName "\\batchJob.scr"))
(alert "End Script")
and you never see "End Script", I think that anything made after the launch of the script will not be executed.
I agree with this "debugging" approach. Most likely the script prematurely ended and never reach the line to delete the file. If a command is cancelled for some reasons, and the script will end
So check your script cassidy_ng