Author Topic: Removing JUNK of CAP 20  (Read 1666 times)

0 Members and 1 Guest are viewing this topic.

Luke

  • Guest
Removing JUNK of CAP 20
« on: February 02, 2007, 11:47:21 AM »
Can anybody tell me how to do the following?

EVERY TIME I close a drawing (by clicking the close X in the top right hand corner) I want the following to happen automatically:

If the layer A-Furn exists delet it and leave the layer that was current as the current layer.  If A-Furn can not be deleted because it is in use, that is fine it can stay.

Set O-snaps to Endpoint, Midpoint & Center

Unload the cui “capdesigner”

Thanks for you help!
Luke

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Removing JUNK of CAP 20
« Reply #1 on: February 02, 2007, 11:59:06 AM »
i would use the drawing close event in VBA
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Removing JUNK of CAP 20
« Reply #2 on: February 02, 2007, 12:16:54 PM »
Put this in acad.dvb file under ThisDrawing
Code: [Select]
Private Sub AcadDocument_BeginClose()
Dim l As AcadLayer
On Error Resume Next
ThisDrawing.SetVariable "osmode", 7
Set l = ThisDrawing.Layers.Item("A-Furn")
l.Delete

End Sub
as for unloading the cui, this is all i could find
Quote
from acad help file

MenuGroup: When a menu group is unloaded from the drawing, any references to the menus and toolbars within that group become invalid. Always delete or set to NULL any references to toolbars and menus that are in the menu group to be unloaded before you unload the menu group.
« Last Edit: February 02, 2007, 12:25:46 PM by CmdrDuh »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

terrycadd

  • Guest
Re: Removing JUNK of CAP 20
« Reply #3 on: February 02, 2007, 12:47:34 PM »
This method seems to only work for the Close command, and the top menu File/Close option. I couldn't get it to work with the upper right [X] close pick method. Also I didn't include the CUI request. I'm not sure how to do it.

Code: [Select]
(command "._undefine" "close")
(defun c:Close ()
  ;Include all last commands before exit here.
  (setvar "OSMODE" 7);endpoint, midpoint, center
  ;Purge layer A-Furn if nothing on it
  (if (and (not (ssget "x" (list '(8 . "A-Furn"))))(tblsearch "LAYER" "A-Furn"))
    (progn
      (if (= (getvar "CLAYER") "A-Furn")
        (setvar "CLAYER" "0");Your choice here
      );if
      (command "PURGE" "A-Furn" "N")
    );progn
  );if
  (command "._qsave")
  (command "._close")
);defun c:Close