Sunday, June 30, 2013

Running a LISP, or Command, on File Open - (Fix_Me)

You can set a LISP utility to run each time you open a drawing from the Project Manager. This is set in the wd.env file. Look for the line that starts with *WD_OPEN_DWG.
         <<Link to my post about the wd.env file>>

“How do I mark a symbol/wire that has a problem, or missing information, and later quickly find it?” Last week this question came up again.

Below is some code that you can find inside of Electrical’s help as sample LISP code. Simply copy and paste it into a text file and save the file as Fix_Me.lsp. APPLOAD this file.

(defun c:fix_me ( / ss en ed xy)
  ; Look for any block insert on the drawing with a block name of "FIX_ME"
  (setq ss (ssget "_X" '((-4 . "<AND")(0 . "INSERT")(2 . "FIX_ME")(-4 . "AND>"))))
  (if (/= ss nil)
    (progn ; one or more found. Zoom up on the first one found
      (setq en (ssname ss 0)) ; entity name of first or only block
      (setq ss nil) ; release the selection set
      (setq ed (entget en))
      (setq xy (cdr (assoc 10 ed))) ; block insertion point
      (command "_.ZOOM" "_CENTER" xy 1.0)
      (princ "\nThis needs attention!!!\n")
  ) )   

Typing ‘fix_me’ will now run the script which zooms in on the first block named fix_me that the script finds. So create a block named fix_me and give it attributes for notes as well as all symbol attributes. This fix_me symbol can then be used when a needed symbol is missing and the engineer is waiting on the CAD Admin to create it. Once the new symbol is finished the fix_me symbol can be swapped (Swap/Update Block) with the new one. Values in the attributes will carry across to the new symbol. It could also be placed off to the side of a symbol with missing catalog info, or anything else the engineer is unsure of at the time of placement.

So once the LISP file and block are created, why not run them each time a drawing is opened? This takes us back to the WD_OPEN_DWG line in the wd.env file. If your block and LISP files are both named fix_me replace the default *WD_OPEN_DWG line with this…
WD_OPEN_DWG,(if(not c:fix_me)(if(setq x(findfile "fix_me.lsp"))(load x)))(if c:fix_me (c:fix_me))

Pretty slick right.

No comments:

Post a Comment