CloudJack Posted February 15, 2017 Share Posted February 15, 2017 I would like to a lisp to do routine. From the photo, I want to delete objects in Area A & Area B for other layout in a drawing. I have tens of drawings to do the same thing. Quote Link to comment Share on other sites More sharing options...
CloudJack Posted February 15, 2017 Author Share Posted February 15, 2017 I found a lisp on internet (can't remenber where) (defun C:F4 ( / current_layout doc plotabs plottablist len K ss2) (setq current_layout (getvar "ctab")) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq plottablist (acad_strlsort plotabs)) (setq len (length plottablist)) (setvar "osmode" 0) (setq K 0) (repeat len (setq name (nth K plottablist)) (if (and (/= name "Model") (/= name current_layout)) (progn (setvar "ctab" name) (command "zoom" "E") ;put what you want to here as many lines as you want like (command "erase" "W" 0,0 50,35 "") (command "erase" "W" '(250 76) '(422 17) "") (command "erase" "W" '(666 70) '(686 60) "") ) ;end progn ) ; end if (setq K (+ K 1)) (setq ss2 '()) ) ; end repeat (setvar "ctab" current_layout) (princ) );defun I dont want to switch each layout during erasing objects. Any idea how to modify this lisp? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 15, 2017 Share Posted February 15, 2017 If you want to do 100's then use a script open dwg1 (load "F4.lsp") f4 close y open dwg2 (load "F4.lsp") f4 close y Quote Link to comment Share on other sites More sharing options...
CloudJack Posted February 16, 2017 Author Share Posted February 16, 2017 It works for AutoCAD 2013. However, in AutoCAD 2015, it will stop after command F4. Here is my script: open dwg1 (load "F4.lsp") f4 _qsave _close open dwg2 (load "F4.lsp") f4 _qsave _close . . . open dwg100 (load "F4.lsp") f4 _qsave _close My updated lisp: (vl-load-com) (defun ss-union ( s1 s2 / si ) (cond ( (null s1) s2) ( (null s2) s1) ( (< (sslength s1) (sslength s2)) (repeat (setq si (sslength s1)) (ssadd (ssname s1 (setq si (1- si))) s2) ) s2 ) ( t (repeat (setq si (sslength s2)) (ssadd (ssname s2 (setq si (1- si))) s1) ) s1 ) ) ) (defun C:E1 ( / current_layout doc plotabs plottablist len K ss2 BBP ssg ss ssw1 ssw2) ; (setq current_layout (getvar "ctab")) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq plottablist (acad_strlsort plotabs)) (setq len (length plottablist)) ; (setvar "osmode" 0) (setq K 0) (repeat len (setq name (nth K plottablist)) (if (/= name "Model") (progn (setvar "ctab" name) (command "zoom" "E") (if (setq ssg (ssget "X" (list '(2 . "Drawing Frame") (cons 410 (getvar "ctab"))))) (progn (setq BBP (cdr (assoc 10 (entget (ssname ssg 0))))) (setq BBP (list (car BBP) (cadr BBP))) (setq wp1 (list (+ (car BBP) 254) (+ (cadr BBP) 65))) (setq wp2 (list (+ (car BBP) 420) (+ (cadr BBP) 20))) (setq wp3 (list (+ (car BBP) 665) (+ (cadr BBP) 70))) (setq wp4 (list (+ (car BBP) 684) (+ (cadr BBP) 62))) ) ) ; (command "zoom" "E") ;put what you want to here as many lines as you want like (command "erase" "W" 0,0 50,35 "") (if (setq ssw1 (ssget "_W" wp1 wp2)) (setq ss (ss-union ss ssw1)) ) (if (setq ssw2 (ssget "_W" wp3 wp4)) (setq ss (ss-union ss ssw2)) ) (if ss (progn (command "_erase" ss "") ; (command "pasteclip" '(0 0 0)) ) ) ) ;end progn ) ; end if (setq K (+ K 1)) (setq ss2 '()) ) ; end repeat ; (command "_qsave") ; (setvar "ctab" current_layout) (princ) );defun Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 17, 2017 Share Posted February 17, 2017 Just a guess (setq ss2 '()) its not used anywhere. Quote Link to comment Share on other sites More sharing options...
Grrr Posted February 17, 2017 Share Posted February 17, 2017 Ronjonp did something similar here, but it erases the window from each layout. However cadplayer posted there a version to modify the selected layouts (using LM's listbox), but you need to register there. ; https://www.theswamp.org/index.php?topic=51868.msg569126#msg569126 (defun c:usewithcaution (/ p1 p2 ss) (vl-load-com) (if (and (= 0 (getvar 'tilemode)) (setq p1 (getpoint "\nSpecify first corner point: ")) (setq p2 (getcorner p1 "\nSpecify other corner point: ")) ) (foreach tab (layoutlist) (setvar 'ctab tab) (and (= 1 (getvar 'cvport)) (vlax-invoke (vlax-get-acad-object) 'zoomwindow p1 p2)) (if (setq ss (ssget "W" p1 p2 (list (cons 410 tab)))) (mapcar 'entdel (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 18, 2017 Share Posted February 18, 2017 Try also (command "F4") or (c:f4) in script Quote Link to comment Share on other sites More sharing options...
CloudJack Posted February 21, 2017 Author Share Posted February 21, 2017 Try also (command "F4") or (c:f4) in script After runing several drawings, and stop at "Restoring cached viewports - Regenerating layout." Script works for 2013 and 2014 version. So, I am not trying to solve why 2015 stop. Thank you BIGAL. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.