Jump to content

andr3flaviano

Recommended Posts

Hello, guys!

I'm new here. So, please, be gentle.

 

I had a problem with a routine. I have to open all the drawings in the same folder, compare a specific area of the drawing with a reference and change that area, if necessary. But I have a lot of references to compare, so I need to do that many times.

 

I've already got a batch to open all the drawings in the same folder. So I just modified it to compare the area with the reference and it worked greatly. The only problem is: When i put that batch inside a loop instruction (to change the reference that will be compared), the batch didn't worked. The following error appears:

 

; error: bad argument type: streamp nil

 

Here goes the code. Could someone help me?

 

(defun c:testloop (/)

(setq c 1)

(while (

(c:opendrawings)

(setq c (1+ c))

); end while

); end function to test the loop

 

 

(defun c:opendrawings (/ dwglist dwgname dwgpre file openfile uhoh len)

(vl-load-com)

(if (and (setq dwgpre (getvar 'dwgprefix))

(setq dwglist (vl-sort (vl-remove (strcat dwgpre (getvar 'dwgname))

(mapcar '(lambda (dwgname) (strcat dwgpre dwgname))

(vl-directory-files dwgpre "*.dwg")

)

)

'

)

)

(setq uhoh

"Readonly drawings will not be processed!"

)

(setq len (strlen uhoh))

)

(progn (setq openfile (open (setq file (strcat dwgpre "myscript.scr")) "w"))

(progn (foreach f dwglist

(if (and

(not (Is_ReadOnly f))

(/= (checkAttFile f) 1)

)

(progn

(write-line (strcat "_.open \"" f "\"") openfile)

(write-line "_.audit _y" openfile)

 

;

 

(write-line "_.qsave _.close" openfile)

)

(setq uhoh (strcat uhoh "\n" f))

)

)

(close openfile)

(command "_.script" file)

(if (= (strlen uhoh) len)

(princ "All drawings successfully processed...")

(alert uhoh)

)

)

)

)

(princ)

); end function to open all the drawings

Link to comment
Share on other sites

Ok! Sorry.

 

Hello, guys!

I'm new here. So, please, be gentle.

 

I had a problem with a routine. I have to open all the drawings in the same folder, compare a specific area of the drawing with a reference and change that area, if necessary. But I have a lot of references to compare, so I need to do that many times.

 

I've already got a batch to open all the drawings. So I modified it to compare the area with the reference and it worked greatly. The only problem is: When i put that batch inside a loop instruction (to change the reference that will be compared), the batch didn't worked. The following error appears:

 

; error: bad argument type: streamp nil

 

Here goes the code. Could someone help me?

 

 

(defun c:testloop (/)
 (setq c 1)
 (while (<= c 5)
   (c:opendrawings)
   (setq c (1+ c))
   ); end while
 ); end function to test the loop

(defun c:opendrawings (/ dwglist dwgname dwgpre file openfile uhoh len)
 (vl-load-com)
 (if (and (setq dwgpre (getvar 'dwgprefix))
   (setq dwglist (vl-sort (vl-remove (strcat dwgpre (getvar 'dwgname))
				     (mapcar '(lambda (dwgname) (strcat dwgpre dwgname))
					     (vl-directory-files dwgpre "*.dwg")
				     )
			  )
			  '<
		 )
   )
   (setq uhoh
	  "Readonly drawings will not be processed!"
   )
   (setq len (strlen uhoh))
     )
   (progn (setq openfile (open (setq file (strcat dwgpre "myscript.scr")) "w"))
   (progn (foreach f dwglist
	    (if	(and
		  (not (Is_ReadOnly f))
		  (/= (checkAttFile f) 1)
		)
	      (progn
		(write-line (strcat "_.open \"" f "\"") openfile)
		(write-line "_.audit _y" openfile)

                           ; <--- Here I put the routines that I need 

		(write-line "_.qsave _.close" openfile)
	      )
	      (setq uhoh (strcat uhoh "\n" f))
	    )
	  )
	  (close openfile)
	  (command "_.script" file)
	  (if (= (strlen uhoh) len)
	    (princ "All drawings successfully processed...")
	    (alert uhoh)
	  )
   )
   )
 )
 (princ)
); end function to open all the drawings

Link to comment
Share on other sites

I do not see anything obviously wrong with the posted code. At what point does the code fail? Is the script created? Posting the code that has been left out may help.

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...