Deleting unused styles en masse?

deltacoolguy
Collaborator
Collaborator

Deleting unused styles en masse?

deltacoolguy
Collaborator
Collaborator

Is there a way to delete (purge) unused styles en masse via the command prompt?  Pipe network structure, pipe, and label styles primarily.  The purge command does not address these types of styles, as far as I can tell.

 

I know how to right-click, and hit "ok" to confirm one style at a time, but that takes time and is very tedious when you need to do dozens.  My company's template has oodles of styles that almost never get used, and I don't want to wade through all that stuff every time I use a pull-down menu.  I know how to get a style back in should I get too aggressive with my deletions, so that is not an issue.

 

Preferably I'd like to write a script so that I can do multiples deletions all at once and quickly.  I would save the script file and use it at the beginning of each new project, and modify it as necessary depending on what is likely to be used on a particular project.

 

I'm fairly decent at writing scripts for basic things like changing color, adding layers, and stuff like that.  But this I'm not sure about.  How do I know what to input for finding the style and ok'ing the deletion via a script?

 

Thanks.

Windows 10-64 Pro
8GB RAM (Home)
12GB RAM (Work)
AutoCAD Civil 3D 2019
0 Likes
Reply
946 Views
8 Replies
Replies (8)

qnologi
Advisor
Advisor
0 Likes

deltacoolguy
Collaborator
Collaborator

@qnologi wrote:

Maybe this will assist...

 

https://knowledge.autodesk.com/support/autocad-civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2015/...


I found that when I did a search before I posted.  That outlines what I call the "long and slow" method.  It's not really efficient for doing dozens at one time.

Windows 10-64 Pro
8GB RAM (Home)
12GB RAM (Work)
AutoCAD Civil 3D 2019
0 Likes

Jeff_M
Consultant
Consultant

@deltacoolguy wrote:

 It's not really efficient for doing dozens at one time.


Really?

 

Command: _PurgeStyles
588 styles purged.

 

Granted, selecting individual styles is a pain with this command. That's why I prefer the one available in the Sincpac.

 

However, to just purge all unused styles, the one in C3D is pretty simple & quick.

Jeff_M, also a frequent Swamper
EESignature
0 Likes

deltacoolguy
Collaborator
Collaborator

@Jeff_M wrote:

@deltacoolguy wrote:

 It's not really efficient for doing dozens at one time.


Really?

 

Command: _PurgeStyles
588 styles purged.

 

Granted, selecting individual styles is a pain with this command. That's why I prefer the one available in the Sincpac.

 

However, to just purge all unused styles, the one in C3D is pretty simple & quick.


Ok, I was not aware of the PurgeStyles command specifically.  I was referring to the generic Purge command, which does not seem to address things like pipe network styles.  It does address things like dimension styles, text styles, etc.

 

Anyway, this is better.  Much better.  And thank you for that.

 

But, in an ideal world, I'd still like to be able to save and run a script, as I'd like to be able to surgically remove only certain styles.  But, I'm sensing that may be impossible, or at least more trouble than it's worth.

 

Windows 10-64 Pro
8GB RAM (Home)
12GB RAM (Work)
AutoCAD Civil 3D 2019
0 Likes

qnologi
Advisor
Advisor

Found this, perhaps someone could assist in making this work for your needs...

 

(defun c:foo ()
(repeat 4
(vl-cmdf "._AECCPURGESTYLES")
(while (eq (logand (getvar "cmdactive") 1) 1)
(command "_Y" "" "")
)
)
)

 

 
qnologi

troma
Mentor
Mentor

@deltacoolguy wrote:
....
I'd like to be able to surgically remove only certain styles.  But, I'm sensing that may be impossible, or at least more trouble than it's worth.

 

 

For a better purge command, with easier ways to deselect/select just the styles you want, please add your vote to this idea.


Mark Green

Working on Civil 3D in Canada

0 Likes

DJGinAZ
Advocate
Advocate

I just commented out the defun and last paren and this solved my issue in my Batch Processing batch/script/lisp tool set for outgoing files. Thanks!

 

 


@qnologi wrote:

Found this, perhaps someone could assist in making this work for your needs...

 

(defun c:foo ()
(repeat 4
(vl-cmdf "._AECCPURGESTYLES")
(while (eq (logand (getvar "cmdactive") 1) 1)
(command "_Y" "" "")
)
)
)

 

 

 

0 Likes

caddie99
Advocate
Advocate
wblock
0 Likes