Jump to content

Delete Specific Layers in Multiple Drawings


omL20Studio

Recommended Posts

Hi All!

 

I'm new to the world of AutoLISP and would appreciate some help. I'd like a lisp routine that deletes specific layers (and any entities within them) from all of the drawings in a particular directory (which I can select at the beginning of the routine). The list of layers can be specific to the routine since all of the drawings have the same ones.

 

I have over 1000 drawings that I need to do this to and I really don't want to have to do them all individually.

 

Thanks in advance for the help!

Link to comment
Share on other sites

ReMark,

 

Heres what i have so far:

 

(defun c:ELAYER (/ aDoc name)
(setvar 'Clayer "0")
(repeat 4
(vla-purgeall
(setq aDoc (vla-get-ActiveDocument
(vlax-get-acad-object)))))
(vlax-for
itm
(vla-get-layers aDoc)
(if (and
(not (wcmatch
(setq name (vla-get-name itm))
"*|*"))
(not (eq name "0"))
(not (member name
'("STREETCL_CENTERLINE"
"SPOT_X_WATER_TEST"
"SPOT_X_GROUND_TEXT"
"SPOT_X_GROUND"
"SPOT_X_BRIDGE_TEXT"
"SPOT_X_BRIDGE"
"RAILROAD_CENTERLINE"
"CONTOUR_SIXHUNDEREDEIGHTYONE"
"CONTOUR_LABEL"
"CONTOUR_INTER_DEP"
"CONTOUR_INTER"
"CONTOUR_INDEX_DEP"
"CONTOUR_INDEX"
"CONTOUR_FOURNINETYTWO"
"SPOT_X_WATER"))))
(progn
(vla-put-lock itm :vlax-false)
(vl-cmdf "_.-laydel" "_N" name "" "_Y"))
)
)
(repeat 4 (vla-purgeall aDoc))
(princ)
)

I get an error on the vlax-get-acad-object command and it doesn't have batch processing yet. any thoughts?

Edited by SLW210
Code Tags
Link to comment
Share on other sites

OK, I fixed the error and now the routine works great. how can I make it a batch process on multiple .dxf drawings in the same folder?

 

(defun c:ELAYER (/ aDoc name)
(setvar 'Clayer "0")
(repeat 4
(vla-purgeall
(setq aDoc (vla-get-ActiveDocument
(vlax-get-acad-object)))))
(vlax-for
itm
(vla-get-layers aDoc)
(if (and
(not (wcmatch
(setq name (vla-get-name itm))
"*|*"))
(not (eq name "0"))
(not (member name
'("STREETCL_CENTERLINE"
"SPOT_X_WATER_TEST"
"SPOT_X_GROUND_TEXT"
"SPOT_X_GROUND"
"SPOT_X_BRIDGE_TEXT"
"SPOT_X_BRIDGE"
"RAILROAD_CENTERLINE"
"CONTOUR_SIXHUNDEREDEIGHTYONE"
"CONTOUR_LABEL"
"CONTOUR_INTER_DEP"
"CONTOUR_INTER"
"CONTOUR_INDEX_DEP"
"CONTOUR_INDEX"
"CONTOUR_FOURNINETYTWO"
"SPOT_X_WATER"))))
(progn
(vla-put-lock itm :vlax-false)
(vl-cmdf "_.-laydel" "_N" name "" "_Y"))
)
)
(repeat 4 (vla-purgeall aDoc))
(princ)
)

Link to comment
Share on other sites

You could evaluate your program through my old Script Writer application, using the following Script Line:

 

_.open *file* (load "[color=red]YourLISP.lsp[/color]" nil) (if [color=red]c:YourCommand[/color] ([color=red]c:YourCommand[/color])) _.qsave _.close

Change the items marked in red as appropriate.

Link to comment
Share on other sites

  • 2 years later...

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