Jump to content

Erase Object in Specific Area at Several Layout


irahalulus

Recommended Posts

Sorry, I'm newbie.

I just want to erase some object (viewport) in Specific Area at Several Layout. Every layout actually have the same position of object.

When this script work, I will make the (repeat n) version....

(defun c:xxxx ()
  (setq p1 (getpoint "\np1: "))
  (setq p2 (getpoint "\np2: "))
  (setq seleksi (ssget "C" p1 p2))
 
  (setvar 'ctab (car (layoutlist))) ; move to first layout
  (command "erase" seleksi "")
  (command "rectangle" p1 p2 "")
  (setvar 'ctab (cadr (member (getvar 'ctab)(layoutlist)))) ; next layout
  (command "erase" seleksi "")
  (command "rectangle" p1 p2 "")
  (setvar 'ctab (cadr (member (getvar 'ctab)(layoutlist))))
  (command "erase" seleksi "")
  (command "rectangle" p1 p2 "")
  (setvar 'ctab (cadr (member (getvar 'ctab)(layoutlist))))
  (command "erase" seleksi "")
  (command "rectangle" p1 p2 "")
  (setvar 'ctab (cadr (member (getvar 'ctab)(layoutlist))))
)

The problem is: for example, the active layout is the 3rd layout, and then I run this script.

It will only erase the object in the 3rd layout. But, it success to make rectangle in every layout...

I have no idea why this can happen. Thx in advance.

 

18849775_deletearea1.jpg.e24b8acc392e16f9e795b499cc0834e2.jpg

 

Link to comment
Share on other sites

If you are in the third layout then the selection set contains entities only in that layout. Similar entities in the same location in other layouts will not be selected. You must  make a selection set in each layout.

 

  (setq p1 (getpoint "\np1: "))
  (setq p2 (getpoint "\np2: "))
  (foreach lout (layoutlist)
	(setq seleksi nil)
	(setq seleksi (ssget "C" p1 p2))
    (command "erase" seleksi "")
    (command "rectangle" p1 p2 "")
  )

 

  • Thanks 1
Link to comment
Share on other sites

14 hours ago, dlanorh said:

If you are in the third layout then the selection set contains entities only in that layout. Similar entities in the same location in other layouts will not be selected. You must  make a selection set in each layout.

 

 

 

Thx in advance. I have gotten the idea.

  • Like 1
Link to comment
Share on other sites

Here's another way without iterating the tabs .. assumes that the viewport is in the EXACT same spot.

(defun c:foo (/ e p s)
  ;; RJP » 2020-05-08
  (if (and (setq e (car (entsel "\nPick viewport to delete: ")))
	   (setq p (vl-remove-if-not '(lambda (x) (member (car x) '(0 10 40 41))) (entget e)))
	   (setq s (ssget "_X" p))
      )
    (foreach vp	(mapcar 'cadr (ssnamex s))
      (vl-catch-all-apply 'vla-delete (list (vlax-ename->vla-object vp)))
    )
  )
  (princ)
)

 

  • Like 1
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...