Close non active DWG without saving

Close non active DWG without saving

hanywillim
Enthusiast Enthusiast
232 Views
1 Reply
Message 1 of 2

Close non active DWG without saving

hanywillim
Enthusiast
Enthusiast

In this lisp i want instead of using SDI (i got some issues with) to close the non active dwg without saving (Mostly will be Drawing 1) 

So, kindly if you can tell me the line of code i should use to do that and be accepted for Most of CAD versions 
Thanks in advance

 

; Start Of Main Function
  (vl-load-com)
	(setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ))
	(setq folder (vlax-invoke-method sh 'BrowseForFolder 0 "" 0 ))
	(vlax-release-object sh)
	(if folder
		(progn
			(setvar "SDI" 1)
			(setvar "LISPINIT" 0)
			(setq folderobject (vlax-get-property folder 'Self))
			(setq result (vlax-get-property FolderObject 'Path))
			(vlax-release-object folder)
			(vlax-release-object FolderObject)
			(setq Files_Folder (vl-directory-files result "*.dwg"))
			;(command "save" (strcat (getvar "dwgprefix") (getvar "dwgname")))
			(setq n 0)
			(while (< n (length Files_Folder))
				(command "fileopen" (strcat result "\\" (nth n Files_Folder)))
				(xpl) ; Explode Polylines 
				(command "-OVERKILL" (ssget "_A") "" "Tolerance" "1" "Ignore" "N" "P" "No" "T" "Yes" "E" "Yes" "A" "Yes" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "C" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "L" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "S" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "LW" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "T" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "TR" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "ST" "done")
				(command "-OVERKILL" (ssget "_A") "" "I" "M" "done")
				(command "-PURGE" "All" "*" "N")
				(if(setq ss(ssget "_A" (list (cons 0 "DIMENSION"))))(command "_.ERASE"ss"" ))
                (blitz2) ; delete dimensions inside blocks
                (dellin1 1) ; delete all lines shorter than
                (flatall) ; flatten everything to 0 elevation
                (setq desktop-dir (strcat (getenv "USERPROFILE") "\\Desktop"))
                (vl-mkdir (strcat desktop-dir "\\Cleaned Drawings\\"))
                (command "_.SAVEAS" "" (strcat desktop-dir "\\Cleaned Drawings\\" (nth n Files_Folder)) "_Yes")

				 
				(setq n (+ 1 n)) ; increment to next dwg 
			 ) ; while loop through all dwgs inside folder
			;(setvar "SDI" 0)
			(setvar "LISPINIT" 1)
			
		 ) ; progn
	 ) ; if folder selected
)

 

 


 

0 Likes
233 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

When running a lisp as soon as you do a "file open" the lisp will cease working.

 

So you have a few choices use a script, use OBDX, use Accoreconsole probably the best option.

 

You can though write a script using lisp that contains open a file, then runs a lisp, save and close, then go onto next file. Look into scriptpro or similar. 

 

This for accoreconsole. https://forums.autodesk.com/t5/forums/replypage/board-id/130/message-id/444989

0 Likes