Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
3,586 Posts
550 Kudos
Registered: ‎12-17-2004
Post 11 of 19

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
140 Posts
0 Kudos
Registered: ‎09-14-2010
Post 12 of 19

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*
6,043 Posts
671 Kudos
Registered: ‎09-13-2004
Post 13 of 19

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*
3,586 Posts
550 Kudos
Registered: ‎12-17-2004
Post 14 of 19

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*
1,660 Posts
191 Kudos
Registered: ‎08-16-2007
Post 15 of 19

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*
3,586 Posts
550 Kudos
Registered: ‎12-17-2004
Post 16 of 19

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*
6,043 Posts
671 Kudos
Registered: ‎09-13-2004
Post 17 of 19

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*
1,660 Posts
191 Kudos
Registered: ‎08-16-2007
Post 18 of 19

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*
3,586 Posts
550 Kudos
Registered: ‎12-17-2004
Post 19 of 19

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!