Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wait for file creation

0 views
Skip to first unread message

spencer1971

unread,
Jul 2, 2004, 11:15:56 AM7/2/04
to
I have posted below a bit of code that is part of a pdf creation lsp that automatically makes a pdf with the dwgname and a rev attribute from the titleblock as its filename.

I have got it working by adding the delay befopre the renaming happens to allow for the pdf to be created but it is a bit hit and miss depending on the speed of the machine it is run on.

Any suggestions on a better way, I have tried to wait for the file to be recognised using various doslib commands but I think the file is there as soon as the pdfcreator starts to make it, but it is still open so the lisp just crashes... Sorry if this is a bit confusing (and long) for a friday afternoon but i think ive run out of ideas..


(defun c:pdf-rev ( / newfile tabname dname dname1 dpref pdfoldname pdfnewname )
(setq oldtile (getvar "tilemode"))
(setvar "tilemode" 0)
(command "plot" "y" "" "PDFcreator" "A3" "m" "l" "n" "e" "1:2" "c" "y" "a3.ctb" "y" "n" "n" "n" "n" "n" "y")
(dos_waitcursor T)
(blocksearch)
(setq tabname (getvar "ctab"))
(setq dname (getvar "dwgname"))
(setq dname1 (substr dname 1 (- (strlen dname) 4)))
(setq dpref (strcat "C:/My Documents/PLOTFILES/"))
(setq pfdoldname (strcat dpref dname1 " " tabname " (1)" ".pdf"))
(setq pdfnewname (strcat dpref dname1 "_" newfile ".pdf"))
(command "delay" 8000)
(dos_delete pdfnewname)
(dos_rename pfdoldname pdfnewname)
(dos_waitcursor)

ECCAD

unread,
Jul 2, 2004, 11:52:05 AM7/2/04
to
Spence,
You might want to try replacing the:
(command "delay" 8000)
With:
(while (not (findfile ".....")))
or some such.
Bob

BillZ

unread,
Jul 2, 2004, 11:57:57 AM7/2/04
to
Why not just name the file to what you want when you plot it?

Or am I way off here.


Bill

spencer1971

unread,
Jul 5, 2004, 6:10:45 AM7/5/04
to
I have already tried that Bob but I think the file exists as soon as the creator starts so the lisp tries to change the name as its being created. , I believe there is a way to check if a file is read-only, this may work, do you know the command for checking this (its something ive seen on this NG but have searched to no avail)

ECCAD

unread,
Jul 5, 2004, 5:13:40 PM7/5/04
to
Yes,
I seem to remember you can check the attrib's of a file by
using DOSLib..

(dos_attrib [filespec [bits]])
Parameters
filespec
The desired file or files. filespec can contain wildcard characters ("*" and "?"). If filespec is not supplied, it is assumed to be *.*.

bits
A bit-coded integer identifying the desired file attributes to set. Specify more than one file attribute by adding the following bit values:

0
Normal

1
Read-only

2
Hidden

4
System

8
Archive

Returns
An association list containing the filenames and the attribute bits if successful.

nil on error.

Example
Command: (dos_attrib "c:\\program files\\autocad 2002\\*.dwg")

(("Drawing1.dwg" . 8) ("Drawing2.dwg" . 8))

-------- from the help file..

Bob

0 new messages