smitaranjan Posted December 22, 2022 Posted December 22, 2022 Hey, Can Anyone help by providing a lisp which will clear all the objects outside of my layout print in all the pages automatically.... please find attachment...I want to keep only object of only the white pages and remove other objects outside of that white space... Thank you in advance Quote
rlx Posted December 22, 2022 Posted December 22, 2022 if your layout has fix coordinates , say 0,0 to 420,297 it would be as simple as (command ".erase" "all" "remove" "window" "0,0" "420,297" "") Quote
smitaranjan Posted December 22, 2022 Author Posted December 22, 2022 1 hour ago, rlx said: if your layout has fix coordinates , say 0,0 to 420,297 it would be as simple as (command ".erase" "all" "remove" "window" "0,0" "420,297" "") How to know the coordinates of my layouts Quote
mhupp Posted December 22, 2022 Posted December 22, 2022 Viewports with the fix option will draw a Viewport at the max print area. (defun C:test (/ vp LL UR) (vl-load-com) (command "_vports" "_F") (setq vp (vlax-ename->vla-object (entlast))) (vla-GetBoundingBox vp 'LL 'UR) (setq LL (vlax-safearray->list LL) UR (vlax-safearray->list UR) ) (command "_.Erase" "All" "Remove" "Window" LL UR "") (vla-delete vp) ) 1 Quote
rlx Posted December 22, 2022 Posted December 22, 2022 a sample drawing would have been nice but mhubb's code could be the answer if your viewports are all over the place , but right now only you can answer that question. Or maybe your viewport sits inside a border or titleblock? In that case you could retrieve the corner points of your titleblock. But is it so much trouble to click on erase yourself , select all , remove window? Of course I agree , one click is better than two or more 1 Quote
BIGAL Posted December 22, 2022 Posted December 22, 2022 Like rlx remove all outside then 2nd step move TITLEBLOCK to 0,0 so all layouts are consistent. Like others need sample dwg. Quote
smitaranjan Posted December 23, 2022 Author Posted December 23, 2022 8 hours ago, rlx said: a sample drawing would have been nice but mhubb's code could be the answer if your viewports are all over the place , but right now only you can answer that question. Or maybe your viewport sits inside a border or titleblock? In that case you could retrieve the corner points of your titleblock. But is it so much trouble to click on erase yourself , select all , remove window? Of course I agree , one click is better than two or more As I have 100s of pages, so it's difficult to select and delete individually Quote
smitaranjan Posted December 23, 2022 Author Posted December 23, 2022 15 hours ago, mhupp said: Viewports with the fix option will draw a Viewport at the max print area. (defun C:test (/ vp LL UR) (vl-load-com) (command "_vports" "_F") (setq vp (vlax-ename->vla-object (entlast))) (vla-GetBoundingBox vp 'LL 'UR) (setq LL (vlax-safearray->list LL) UR (vlax-safearray->list UR) ) (command "_.Erase" "All" "Remove" "Window" LL UR "") (vla-delete vp) ) yes, its working....but have to apply it in each layout...can you modify the code to apply all the layout at once Quote
rlx Posted December 23, 2022 Posted December 23, 2022 (edited) just added a tiny bit to Mhupp's perfect code (and totally untested) (defun c:test () (foreach lay (layoutlist) (command "LAYOUT" "S" Lay) (command "_vports" "_F") (setq vp (vlax-ename->vla-object (entlast))) (vla-GetBoundingBox vp 'LL 'UR) (setq LL (vlax-safearray->list LL) UR (vlax-safearray->list UR)) (command "_.Erase" "All" "Remove" "Window" LL UR "") (vla-delete vp) ) (princ) ) you may want to remove "Model" from layoutlist Edited December 23, 2022 by rlx added command - layout-set-lay 1 Quote
BIGAL Posted December 23, 2022 Posted December 23, 2022 No model using (layoutlist) (setq lays (layoutlist)) ("D01" "D02") Yes if use (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) D01D02Model Quote
rlx Posted December 23, 2022 Posted December 23, 2022 7 minutes ago, BIGAL said: No model using (layoutlist) (setq lays (layoutlist)) ("D01" "D02") Yes if use (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) D01D02Model you are correct @bigal , I was about to edit the code when I noticed I didn't need to (vl-)remove "Model" but forgot to remove the remark... Quote
smitaranjan Posted December 27, 2022 Author Posted December 27, 2022 On 12/23/2022 at 7:09 PM, rlx said: just added a tiny bit to Mhupp's perfect code (and totally untested) (defun c:test () (foreach lay (layoutlist) (command "LAYOUT" "S" Lay) (command "_vports" "_F") (setq vp (vlax-ename->vla-object (entlast))) (vla-GetBoundingBox vp 'LL 'UR) (setq LL (vlax-safearray->list LL) UR (vlax-safearray->list UR)) (command "_.Erase" "All" "Remove" "Window" LL UR "") (vla-delete vp) ) (princ) ) you may want to remove "Model" from layoutlist @rlx why model objects also deleted and applies only 10 layouts not beyond that Quote
rlx Posted December 27, 2022 Posted December 27, 2022 can't really tell without actual drawing. You can send picture of your car to a garage and ask why it doesn't start but there is only so much you can tell from a picture you know... also haven't tested code from mhupp , just added a way to go through layouts. I probably would have used ssget to select all objects on current layout instead of erase all but you stated it worked for you so for me that's where it ended and assumed we all lived happily ever after... Quote
BIGAL Posted December 28, 2022 Posted December 28, 2022 Like rlx without a dwg can not look at what is in some of your layouts. The code uses a viewport for me would look for a title block, so if you have 12 layouts and only 10 processed chances are 2 layouts don't have a viewport. The dwg just needs the layouts remove anything that you don't want people to see repalce with a couple of circles. Quote
rlx Posted December 28, 2022 Posted December 28, 2022 like @bigal , you can strip out all your secrets first and / or send your sample drawing by PM (private mail) to any of us so all of your secrets will be safe. Quote
smitaranjan Posted December 28, 2022 Author Posted December 28, 2022 5 hours ago, rlx said: like @bigal , you can strip out all your secrets first and / or send your sample drawing by PM (private mail) to any of us so all of your secrets will be safe. Please find attachment dwg, andGEORGIA.dwg? if possible can you develop a lisp code for the auto matchline also shared an snip of my matchline block.... Thank you for helping Quote
mhupp Posted December 28, 2022 Posted December 28, 2022 (edited) Using the title block instead of creating a viewport (defun c:Clean (/ ss tblk LL UR ss1 ss2) (command "_.Undo" "BE") (setvar 'cmdecho 0) (foreach lay (layoutlist) (setvar 'ctab lay) (command "_.Zoom" "E") (if (and (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "GP1117_21" ) (cons 410 lay)))) (= (sslength ss) 1)) (progn (setq tblk (vlax-ename->vla-object (ssname ss 0))) (vla-GetBoundingBox tblk 'LL 'UR) (setq LL (vlax-safearray->list LL) UR (vlax-safearray->list UR) ) (if (and (setq ss1 (ssget "_A" (list (cons 410 lay)))) (setq ss2 (ssget "_W" LL UR (list (cons 410 lay))))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss2))) (ssdel ent ss1) ) ) (ssdel (ssname ss 0) ss1) (command "_.Erase" SS1 "") (command "_.Zoom" "E") ) ) ) (setvar 'cmdecho 1) (command "_.Undo" "E") (princ) ) Edited December 28, 2022 by mhupp 2 Quote
rlx Posted December 28, 2022 Posted December 28, 2022 (edited) Just tested mhupp's code and it looks like it's working just fine , well done mhupp Edited December 28, 2022 by rlx 1 1 Quote
BIGAL Posted December 28, 2022 Posted December 28, 2022 (edited) Agree title block is way to go. Re find match line is on my to do list but do not ask when it wil be avaialble, needs some data to be stored inside the viewport like a sheet number. I know what you want, have a client sample dwg that is like a 3x6 grid of layouts. Need refs on 4 sides. Have step 1 a make layouts from rectangs in model. Edited December 28, 2022 by BIGAL Quote
smitaranjan Posted December 29, 2022 Author Posted December 29, 2022 1 hour ago, BIGAL said: Agree title block is way to go. Re find match line is on my to do list but do not ask when it wil be avaialble, needs some data to be stored inside the viewport like a sheet number. I know what you want, have a client sample dwg that is like a 3x6 grid of layouts. Need refs on 4 sides. Have step 1 a make layouts from rectangs in model. Okay...please try...should I send you the dwg again by making in rectangular viewport Quote
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.