TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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]
-
Purge all and save. Currently set to purge four times. You can set it to whatever you desire.
;;;=====================================================================;
;;;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.
-
I don't think so Randy. I don't think qaflags will stifle it either. You'd probably have to hand roll some arx.
-
Will mine do it? I've never had a problem. Did I not understand the question?
-
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:
I want to automatically purge SOME stuff (I sorta know about vla-purgeall), not everything.
-
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.
-
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.
-
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:
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.
-
Would require a fair bit of coding, albeit mostly trivial.
ummm... I can live with the echos, just hoping for an "Easy Button".
-
BTW, Daron, I have one from D.M. Stien's Visual Lisp Bibile.
-
Randy, will this work for ya? I wasn't able to determine where the Shape file info is stored......
(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)
)
-
Schweeeeet!!
Although you left out Layers and Blocks!
Very Cool Jeff!!!
I likes alot! :D :D :D
:dood: :dood: :dood:
-
Although you left out Layers and Blocks!
Very Cool Jeff!!!
Thanks!
As for leaving things out........... but I don't want to purge Blocks and Layers, just everything else.
8)
-
:?
sorry
-
That's pretty cool, thanks, but it's not getting rid of PLOTSTYLES that can be PURGEd.
Any ideas?
-
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.
(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)
)
-
Of course, excellent outside the box solution Jeff. I use the technique for blowing away appids, why not other tables.
<KickSelfForMissingTheObvious.mpg>
:)
-
Wayyy cool Jeff, thanks a heap. I knew somebody 'round here had the answer.
-
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.
-
I dunno, I couldn't get NOMUTT to work with PURGE.
-
The first thing I tried was NOMUTT. Somehow, Purge overrides the NOMUTT setting and lists everything purged, or not, no matter what.
-
On another topic.......how would you change the drawing viewres silently?
-
cmdecho 0?
-
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.
-
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.
-
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
-
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?
-
... but VBA doesn't mutter.
Either does the lisp solution I posted for Randy..... :D
-
sorry, i quickly scanned and didn't read the whole thread