Try this....(for single drawing).....
(defun c:rob (/ p1 p2)
(setq p1 (list -0.5 -0.5 0))
(setq p2 (list 34.5 22.5 0))
(command "erase" "all" "r" "w" p1 p2 "")
(command "zoom" "e")
)
For.....
@Anonymous wrote:
We are converting a ton of files from Microstation to AutoCAD and the Microstation users leave tons of crap outside the border. I searching for a lisp routine which can select and delete everything outside a specific set of coordinates (No user input!) so I can run this in a batch environment. So if the border 22x34 and starts at (Specify point: X = 0 Y = 0 Z = 0) and goes to (Specify point: X = 34 Y = 22 Z = 0). Then everything outside of this area on all 4 sides would be selected and deleted and at the end do a Zoom E to recenter the drawings.
Try this.......
First put all the drawings in a single folder & run the code it will ask to select the Folder Containing the drawings you just select the folder & move forward......Code will work itself on all the drawings in side that folder.....
But before running the Lisp make sure about two things-
1. There is only one Drawing is open (other than any drawing which one you want to edit), otherwise SDI Variable can not be reset.
2. Wait for complete execution of the command, otherwise SDI Variable will not restored back.
(defun c:Del_obj ( / sh folder folderobject result)
(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)
(setq SDI_Val (getvar "SDI"))
(setq LISPI_Val (getvar "LISPINIT"))
(vl-cmdf "SDI" 1)
(vl-cmdf "LISPINIT" 0)
(if folder
(progn
(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")) "Y")
(setq n 0)
(while (< n (length Files_Folder))
(command "fileopen" (strcat result "\\" (nth n Files_Folder)))
(setq p1 (list -0.5 -0.5 0))
(setq p2 (list 34.5 22.5 0))
(command "erase" "all" "r" "w" p1 p2 "")
(command "zoom" "e")
(vl-cmdf "save" (strcat result "\\" (nth n Files_Folder)))
(setq n (+ 1 n))
)
)
)
(vl-cmdf "SDI" SDI_Val)
(vl-cmdf "LISPINIT" LISPI_Val)
)
Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....