Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
hmsilva
Posts: 2,873
Registered: ‎12-17-2004
Message 11 of 19 (107 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 05:01 AM in reply to: dbroad

dbroad wrote:

This is a prime example of where we who are in the know, should either ignore such requests or to try to solve them in the least destructive way possible.  It's akin to a parent who doesn't let their children play with daddy's Uzi just cause they ask nicely.


Agree...

 

Henrique

Distinguished Contributor
msarqui
Posts: 134
Registered: ‎09-14-2010
Message 12 of 19 (104 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 05:12 AM in reply to: msarqui

Hello everyone!

 

Thanks for all answers and suggestions.


We have used defpoints to viewports and other objects that we don't want to see in the plotting for more then 12 years, even before Autocad give to us the possibility to make a non-plot layer. So, this is a hard thing to change in the office standards.


That said, thanks to Henrique. Your code do exactly what I want and is pretty fast, even in the large drawings. I will test it in more drawings and I will let you know about future issues.

 

Cheers

Marcelo Silva

*Expert Elite*
Kent1Cooper
Posts: 5,513
Registered: ‎09-13-2004
Message 13 of 19 (100 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 06:00 AM in reply to: dbroad

dbroad wrote:

... I would also skip point entities from deletion.  Otherwise, all the dimension blocks will be without their point entities.  Also, points on defpoints are an important feature of some verticals.  I also use them in my own block design.


If the OP's situation doesn't involve such verticals, and if they do want to remove any independent Point entities there may be on that Layer, then my earlier suggestion works fine -- it does not "see" the definition points in Dimension entities, so they won't be removed.  If you skip them entirely for the purpose of retaining them in Dimensions, things the OP wants removed may not be.  If they want even nested objects on that Layer, other than Dimension definition points, removed, then mine won't get them, but I imagine the through-the-blocks approach could be made to distinguish nested Points within Dimensions from any other Points, and get rid of only the latter.

Kent Cooper
*Expert Elite*
hmsilva
Posts: 2,873
Registered: ‎12-17-2004
Message 14 of 19 (92 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 06:51 AM in reply to: msarqui

msarqui wrote:
..., thanks to Henrique. Your code do exactly what I want and is pretty fast, even in the large drawings. I will test it in more drawings and I will let you know about future issues.

You're welcome, Marcelo!

Glad I could help

 

Henrique

*Expert Elite*
dbroad
Posts: 1,573
Registered: ‎08-16-2007
Message 15 of 19 (83 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 07:27 AM in reply to: Kent1Cooper

Good point Kent.  Your method would not affect any of the AutoCAD internal use of defpoints as in below.  But browsing blocks via ActiveX must be done very carefully since it is a layer automatically created by Autodesk and should be managed by Autodesk.

 

(defun c:cleandp()(command "_.erase" (ssget "x" '((8 . "defpoints") (0 . "~viewport")))"")(princ))

*Expert Elite*
hmsilva
Posts: 2,873
Registered: ‎12-17-2004
Message 16 of 19 (74 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 07:42 AM in reply to: dbroad

dbroad wrote:

Good point Kent.  Your method would not affect any of the AutoCAD internal use of defpoints as in below.  But browsing blocks via ActiveX must be done very carefully since it is a layer automatically created by Autodesk and should be managed by Autodesk.

 

(defun c:cleandp()(command "_.erase" (ssget "x" '((8 . "defpoints") (0 . "~viewport")))"")(princ))


To erase all objects in defpoints in all layouts, we'll have to step through all layouts and run the erase command in each layout...

 

Henrique

*Expert Elite*
Kent1Cooper
Posts: 5,513
Registered: ‎09-13-2004
Message 17 of 19 (66 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 08:27 AM in reply to: hmsilva

hmsilva wrote:

dbroad wrote:

.... 

(defun c:cleandp()(command "_.erase" (ssget "x" '((8 . "defpoints") (0 . "~viewport")))"")(princ))


To erase all objects in defpoints in all layouts, we'll have to step through all layouts and run the erase command in each layout...

....


Or use (entdel) -- see the end of Message 4.

Kent Cooper
*Expert Elite*
dbroad
Posts: 1,573
Registered: ‎08-16-2007
Message 18 of 19 (58 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 08:43 AM in reply to: Kent1Cooper

Thanks.  Not concentrating today.  This is a way to use activeX without going into block definitions other than layouts.

(defun c:cleandp ()
  (ssget "x" '((8 . "defpoints") (0 . "~viewport")))
  (vlax-for n
	      (vla-get-activeselectionset
		(vla-get-activedocument
		  (vlax-get-acad-object)
		  )
		)
    (vla-delete n)
    )

  (princ)
  )

 

*Expert Elite*
hmsilva
Posts: 2,873
Registered: ‎12-17-2004
Message 19 of 19 (54 Views)

Re: Delete all objects in a layer but viewports

04-30-2014 08:52 AM in reply to: Kent1Cooper

Kent1Cooper wrote:

Or use (entdel) -- see the end of Message 4.



You're correct, I didn't read the full post...

 


dbroad wrote:

Thanks.  Not concentrating today.  This is a way to use activeX without going into block definitions other than layouts.

(defun c:cleandp ()
  (ssget "x" '((8 . "defpoints") (0 . "~viewport")))
  (vlax-for n
	      (vla-get-activeselectionset
		(vla-get-activedocument
		  (vlax-get-acad-object)
		  )
		)
    (vla-delete n)
    )

  (princ)
  )

 


 

Nice approach!

 

Henrique

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.