Jump to content

Routine claims it can't find file, then it loads the proper file anyway


benhubel

Recommended Posts

I am using a loop which includes command.open to load files sequentially. Every time it tries to load the next file, it pauses the routine to display a message which reads:

"Cannot find the specified drawing file.

Please verify that the network drive is available and the file exists."

When I click "OK", the program proceeds to properly open the file anyway and then it carries on with the rest of the program. I'm happy with how it runs except that I have to hit enter between every file load to remove the message and un-pause the routine.

 

What is it that's going wrong to cause this message to pop up and how do I fix this? If nothing else, I'm fine with finding a way to simply suppress the message, as everything works perfectly otherwise.

 

The code is as follows (please forgive the terribly hacked code. I have no real knowledge of what I'm doing):

 

;Open and Trim
(Defun C:oat () ;define Open and Trim
;	(c:wwc) ;run WriteWithinCurve
;	(setvar "cmdecho" 0)
(If(/= nil writewithincurvedirectory)(princ (strcat "\nCurrent directory is:\n" writewithincurvedirectory))) ;display current path
(princ "\n")

(setvar "SDI" 1)
(command "FILEDIA" 0) ;Set open dialog to be command line only
(setq DXFFilesArray (vl-directory-files writewithincurvedirectory "*.dxf")) ;Find all .dxf files in current folder.
(princ DXFFilesArray) ;display contents of current target directory
(princ "\n") ;newline for aesthetic purposes
(setq LoopIndex 0) ;initialize loop index
(repeat (length DXFFilesArray) ;repeat once for each .dxf file in DXFFilesArray
;	(repeat (3) ;repeat once for each .dxf file in DXFFilesArray
	(setq FileToOpenFullPath (strcat writewithincurvedirectory (nth LoopIndex DXFFilesArray))) ;get current folder to write file to and add the .dxf name to it
	(princ (strcat "\nFile to open is: " FileToOpenFullPath "\n")) ;display filename
	(setq LoopIndex (1+ LoopIndex))
	(command "_.OPEN" "_Y" FileToOpenFullPath)
;		(OpenDwgFile FileToOpenFullPath)
	(C:ty) ;Trim Yellow
)
(setvar "filedia" 1) ;Restore open dialogue to have a visual interface
(princ)
(setvar "cmdecho" 1)
;	(command "_QUIT" "_Y") ;close AutoCAD
)

; (defun OpenDwgFile (arg1 / )
 ; (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) arg1))
; ); defun

Link to comment
Share on other sites

Few remarks (if interested):

 

You could use something like this, to prevent eventual crashing:

(if (eq 'SUBR (type C:test)) (C:test))

For these function calls:

(c:wwc) ;run WriteWithinCurve
(C:ty) ;Trim Yellow

 

 

(If(/= nil writewithincurvedirectory)(princ (strcat "\nCurrent directory is:\n" writewithincurvedirectory))) ;display current path

This is the same as the above line, the (/= nil ...) check is redundant:

(if writewithincurvedirectory (princ (strcat "\nCurrent directory is:\n" writewithincurvedirectory))) ;display current path

 

 

Altho this is a comment, it will error, because it will look for a function with name 3 (when you decide to uncomment it):

;	(repeat (3) ;repeat once for each .dxf file in DXFFilesArray

So just leave the integer:

;	(repeat 3 ;repeat once for each .dxf file in DXFFilesArray

Edited by Grrr
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...