TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CADaver on June 17, 2005, 10:48:32 AM

Title: Silent Purge
Post by: CADaver on June 17, 2005, 10:48:32 AM
I want to automatically purge SOME stuff (I sorta know about vla-purgeall), not everything.  Anyway, I hobbled together a routine using  (command "-purge" and works fine EXCEPT it echos whats being purged to the screen (even when CMDECHO is off). <see below>  Is there some way to so this silently?  Or some other way entirely, that will "auto" purge specific stuff without kicking up a fuss?

Deleting dimension style "dim120".
Deleting dimension style "Standard".
2 dimension styles deleted.
Deleting linetype "HANDRAIL".
Deleting linetype "MATCHLINE".
Deleting linetype "REBAR-01".
Deleting linetype "REBAR02".
Deleting linetype "REBAR04".
Deleting linetype "REBAR05".
Deleting linetype "TOPLINE23".
7 linetypes deleted.
Deleting plotstyle "ByLayer".
Deleting plotstyle "Extra Thin".
Deleting plotstyle "Medium".
Deleting plotstyle "Style_1".
Deleting plotstyle "Style_2".
Deleting plotstyle "Style_3".
Deleting plotstyle "Style_4".
7 plotstyles deleted.
Deleting text style "btxt120".
Deleting text style "btxt240".
Deleting text style "Dimn".
Deleting text style "txt120".
4 text styles deleted.
Deleting shape file "ltypeshp.shx".
1 shape file deleted.
[/list:u]
Title: Silent Purge
Post by: daron on June 17, 2005, 10:57:42 AM
Purge all and save. Currently set to purge four times. You can set it to whatever you desire.
Code: [Select]
;;;=====================================================================;
;;;Purgeall and save ;
;;;=====================================================================;
(defun c:purgesave (/ $acad $doc)
     (setq $doc (vla-get-activedocument (vlax-get-acad-object)))
     (repeat 4
 (vla-purgeall $doc)
     )
     (vla-save $doc)
     (vlax-release-object $doc)
     (princ
 "\nDrawing has been completely purged and successfully saved. "
     )
     (princ)
)
You can also remove the vla-save if you don't wish to autosave.
Title: Silent Purge
Post by: MP on June 17, 2005, 10:57:44 AM
I don't think so Randy. I don't think qaflags will stifle it either. You'd probably have to hand roll some arx.
Title: Silent Purge
Post by: daron on June 17, 2005, 10:58:56 AM
Will mine do it? I've never had a problem. Did I not understand the question?
Title: Silent Purge
Post by: MP on June 17, 2005, 10:59:49 AM
Quote from: daron
Purge all and save. Currently set to purge four times. You can set it to whatever you desire ... <snip> ...You can also remove the vla-save if you don't wish to autosave.

Umm:
Quote from: Randy
I want to automatically purge SOME stuff (I sorta know about vla-purgeall), not everything.
Title: Silent Purge
Post by: CADaver on June 17, 2005, 11:02:49 AM
Quote from: MP
I don't think so Randy. I don't think qaflags will stifle it either. You'd probably have to hand roll some arx.
I played with qaflags a little but didn't see a way around it there.  Looks like I'll live with the echo for a while.

Daron, I just want to purge SOME stuff, not all.  I have a function (surprisingly similar to yours) that does a purge ALL, but I don't want to purge Blocks and Layers, just everything else.
Title: Silent Purge
Post by: MP on June 17, 2005, 11:06:27 AM
A cludgy work around would be to make a reference to anything you do wish to keep (that is currently not referenced), say a block def, a layer or a text style, do a vla-purgeall, then delete the temporary references. Would require a fair bit of coding, albeit mostly trivial.
Title: Silent Purge
Post by: daron on June 17, 2005, 11:07:02 AM
Quote from: MP
Quote from: daron
Purge all and save. Currently set to purge four times. You can set it to whatever you desire ... <snip> ...You can also remove the vla-save if you don't wish to autosave.

Umm:
Quote from: Randy
I want to automatically purge SOME stuff (I sorta know about vla-purgeall), not everything.


Saw that. Didn't read well to me. Heh. I don't even use mine anymore because if I purge any blocks or layers it kills the whole program I have to use. Poor scripting. example: "layer" "s"...:?: Grrr.
Title: Silent Purge
Post by: CADaver on June 17, 2005, 11:41:31 AM
Quote from: MP
Would require a fair bit of coding, albeit mostly trivial.
ummm... I can live with the echos, just hoping for an "Easy Button".
Title: Silent Purge
Post by: CADaver on June 17, 2005, 11:50:46 AM
BTW, Daron, I have one from D.M. Stien's Visual Lisp Bibile.
Title: Silent Purge
Post by: Jeff_M on June 17, 2005, 12:59:40 PM
Randy, will this work for ya? I wasn't able to determine where the Shape file info is stored......
Code: [Select]

(defun c:cpurge (/ doc)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (mapcar '(lambda (col)
    (vlax-for x col
      (vl-catch-all-apply 'vla-delete (list x))
      )
    )
 (list (vla-get-dimstyles doc) (vla-get-linetypes doc)
(vla-get-textstyles doc) (vla-get-plotconfigurations doc)
)
 )
  (princ)
  )
Title: Silent Purge
Post by: whdjr on June 17, 2005, 01:12:54 PM
Schweeeeet!!

Although you left out Layers and Blocks!

Very Cool Jeff!!!

I likes alot! :D  :D  :D  
:dood:  :dood:  :dood:
Title: Silent Purge
Post by: Jeff_M on June 17, 2005, 02:47:51 PM
Quote from: whdjr

Although you left out Layers and Blocks!

Very Cool Jeff!!!
Thanks!
As for leaving things out.......
Quote from: CADaver
.... but I don't want to purge Blocks and Layers, just everything else.


 8)
Title: Silent Purge
Post by: whdjr on June 17, 2005, 02:50:09 PM
:?

sorry
Title: Silent Purge
Post by: CADaver on June 17, 2005, 04:22:29 PM
That's pretty cool, thanks, but it's not getting rid of PLOTSTYLES that can be PURGEd.  
Any ideas?
Title: Silent Purge
Post by: Jeff_M on June 17, 2005, 06:16:45 PM
Here ya go. I don't use plotstyles so I tried this on a small test dwg and it appearred to work. If it doesn't work like you think it should, let me know and I'll investigate further.
Code: [Select]

(defun c:cpurge (/ doc del_itms pstyl n namelist styls sub)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq pstyl (vla-item (vla-get-dictionaries doc) "ACAD_PLOTSTYLENAME"))
  (mapcar '(lambda (col)
    (vlax-for x col
      (vl-catch-all-apply 'vla-delete (list x))
      )
    )
 (list (vla-get-dimstyles doc) (vla-get-linetypes doc)
(vla-get-textstyles doc) (vla-get-plotconfigurations doc)
)
 )
  (vlax-for lay (vla-get-layers doc)
    (if (not (member (vla-get-plotstylename lay) namelist))
      (setq namelist (cons (vla-get-plotstylename lay) namelist))
      )
    )
  (setq styls (entget (vlax-vla-object->ename pstyl))
sub (member (assoc 3 styls) styls)
sub (reverse (cddr (reverse sub)))
n 0)
  (while (< (setq n (+ n 2)) (1- (length sub)))
    (if (not (member (cdr (nth n sub)) namelist))
      (setq del_itms (cons (vla-get-objectid (vlax-ename->vla-object (cdr (nth (1+ n) sub)))) del_itms))
      )
    )
  (vlax-for itm pstyl
    (if (member (vla-get-objectid itm) del_itms)
      (vla-delete itm)
      )
    )  
  (princ)
  )
Title: Silent Purge
Post by: MP on June 17, 2005, 07:29:04 PM
Of course, excellent outside the box solution Jeff.  I use the technique for blowing away appids, why not other tables.

<KickSelfForMissingTheObvious.mpg>

:)
Title: Silent Purge
Post by: CADaver on June 17, 2005, 08:08:59 PM
Wayyy cool Jeff, thanks a heap.  I knew somebody 'round here had the answer.
Title: Silent Purge
Post by: Chuck Gabriel on June 17, 2005, 10:36:27 PM
I may be a little late with this, but maybe it will come in handy in the future.  There is a system variable called NOMUTT.  If you set it to one, nothing (and I mean nothing) will appear on the command line unless you specifically put it there.
Title: Silent Purge
Post by: CADaver on June 18, 2005, 08:19:53 AM
I dunno, I couldn't get NOMUTT to work with PURGE.
Title: Silent Purge
Post by: Jeff_M on June 19, 2005, 11:17:08 AM
The first thing I tried was NOMUTT. Somehow, Purge overrides the NOMUTT setting and lists everything purged, or not, no matter what.
Title: Silent Purge
Post by: ronjonp on June 20, 2005, 11:13:04 AM
On another topic.......how would you change the drawing viewres silently?
Title: Silent Purge
Post by: daron on June 20, 2005, 11:16:15 AM
cmdecho 0?
Title: Silent Purge
Post by: Jeff_M on June 22, 2005, 04:47:31 PM
Quote from: ronjonp
On another topic.......how would you change the drawing viewres silently?
Well, contrary to what the help file says, VIEWRES is NOT a System Variable, so a simple (setvar "viewres" 10000) is out ......
However, this setting is stored for each individual Viewport. Since you can't use ENTMOD on a Viewport object, the only way (other than the command version) to modify it is with the ActiveX property "ArcSmoothness" of a PSViewport or Viewport object.
Title: Silent Purge
Post by: Chuck Gabriel on June 28, 2005, 07:00:25 PM
Quote from: Jeff_M
The first thing I tried was NOMUTT. Somehow, Purge overrides the NOMUTT setting and lists everything purged, or not, no matter what.


Sorry for the bum steer.  I thought for sure it would work.
Title: Silent Purge
Post by: Jeff_M on June 28, 2005, 08:25:08 PM
No problem, Chuck. I thought it would work, too, when I tested it. FYI, that's 2 things NOMUTT doesn't work with (at least in 2002): Purge and Dimstyle->Save
Title: Silent Purge
Post by: David Hall on June 29, 2005, 11:09:02 AM
Not to throw in a huge monkey wrench, but VBA doesn't mutter.  Is it possible to use a vb app called from your lisp?
Title: Silent Purge
Post by: Jeff_M on June 29, 2005, 12:08:31 PM
Quote from: CmdrDuh
... but VBA doesn't mutter.
Either does the lisp solution I posted for Randy.....  :D
Title: Silent Purge
Post by: David Hall on June 29, 2005, 12:41:55 PM
sorry, i quickly scanned and didn't read the whole thread