Jump to content

Clear out outside of the layout object


smitaranjan

Recommended Posts

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

 

image.thumb.png.4902e5ae8b8001e3cb198e0ec72622aa.png

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

  • Like 1
Link to comment
Share on other sites

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 😁

  • Like 1
Link to comment
Share on other sites

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 😀

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

:xmas:

Edited by rlx
added command - layout-set-lay
  • Like 1
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

:xmas:

@rlx why model objects also deleted and applies only 10 layouts not beyond that

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

image.png.f52f5f50d8c3dbcd11c8a87ef664c554.png

 

Link to comment
Share on other sites

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 by mhupp
  • Thanks 2
Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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 

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