Jump to content

Selective xref unloading


crgonzo

Recommended Posts

I have a little lisp routine that calls a script file for xref unloading.  My desire is to unload all other xrefs of similar type but keep either of the 3 xrefs shown in the code.  To clarify, I have 3 engineers seals that I use in my group but there are several other possible engineer seals that get attached from another group.  If any of my 3 seals is attached, I would like to automatically unload all others.  The code I'm using is below.  It's cumbersome and unreliable since engineers come and go which requires the script to be modified on a regular basis.

 

; unloads extraneous engineer seals
; but keeps electrical seals



(defun c:bs ()

(cond
((tblsearch "block" "seal-jas")
(command "script" "C:\\crg\\Scripts\\badseal-unload.scr"))
((tblsearch "block" "seal-mac")
(command "script" "C:\\crg\\Scripts\\badseal-unload.scr"))
((tblsearch "block" "seal-pkp")
(command "script" "C:\\crg\\Scripts\\badseal-unload.scr"))
(t nil)
);cond
);defun
 

thanks in advance

Link to comment
Share on other sites

You probably shouldn't preload their seals and remove the ones you don't need/want. Instead have a command to only load the ones you need.

 

Give this a try.

(defun C:KEEP (/ lst rep seal)
  (setq lst (list "seal-jas" "seal-mac" "seal-pkp"))
  (initget "jas mac pkp")
  (setq rep (getkword "\nKeep [jas mac pkp]: "))
  (foreach seal lst
    (if (not (vl-string-search rep seal))
      (command "-xref" "_U" seal)
    )
  )
)

 

Link to comment
Share on other sites

I agree.  Problem is that I can't control who or when.  We have 2 disciplines working with the same border files and the other group throws in their engineer stamps willy nilly.  It's the wild west around here.  Thanks for your response.  I'll give it a try right now.

Link to comment
Share on other sites

Mhupp, got it to work.  The list portion effectively duplicates my script file.  Is it possible to have the program automatically unload the offenders rather than type in the seal to keep?  It would be good to have the program read which "good" seal is actually loaded then unload the others.  If it's not possible, that's ok because this does work.  Thanks again

Link to comment
Share on other sites

My final.  Took another stab at it.  This is a bit more automatic. Tossed it in the Startup Suite.

 

; 01/24/2023
;
(defun C:KEEP (/ lst rep seal)

  (setq lst (list "seal-jas" "seal-mac" "seal-pkp" "seal-bew" "seal-sal" "seal-sy" 
   "seal-sr" "seal-ukg" "seal-smt" "seal-aep" "seal-pjn" "seal-wc" "seal-crg"))

(cond
((tblsearch "block" "seal-jas") (setq rep "jas"))
((tblsearch "block" "seal-mac") (setq rep "mac"))
((tblsearch "block" "seal-pkp") (setq rep "pkp"))
(t nil)
);cond

  (foreach seal lst
    (if (not (vl-string-search rep seal))
      (command "-xref" "_U" seal)
    )
  )

);defun

(C:KEEP)
 

Link to comment
Share on other sites

Cleaned up the code a little.

 

(defun C:KEEP (/ lst x)
  (setvar 'cmdecho 0)
  (foreach seal '("jas" "mac" "pkp")
    (if (not (tblsearch "block" (setq x (strcat "seal-" seal))))
      (command "-Xref" "_U" x)
    )
  )
  (command "-Xref" "_U" "seal-bew,seal-sal,seal-sy,seal-sr,seal-ukg,seal-smt,seal-aep,seal-pjn,seal-wc,seal-srg")
  (setvar 'cmdecho 1)
  (princ)
)
(C:KEEP)

 

  • Like 1
Link to comment
Share on other sites

2 hours ago, crgonzo said:

The list portion effectively duplicates my script file.

 

Someone correct me if I'm wrong but you should only use a script file is if you have multiple drawings you want to run a commands on.

Edited by mhupp
Link to comment
Share on other sites

9 hours ago, mhupp said:

 

Someone correct me if I'm wrong but you should only use a script file is if you have multiple drawings you want to run a commands on.

I am guessing 'script' means LISP, and not script as you would do it....

Link to comment
Share on other sites

2 hours ago, Steven P said:

I am guessing 'script' means LISP, and not script as you would do it....

 

In their first post

 

(command "script" "C:\\crg\\Scripts\\badseal-unload.scr"))

Link to comment
Share on other sites

As stated in the beginning, cumbersome and unreliable.  However, it worked as required.  I usually have between 30 and 200 files that need to be dealt with so the script was handy at first.  Then I decided it would be better to try NOT to have a list of offending xrefs but, rather, to recognize one of 3 desired xrefs and unloading remaining "SEAL-" xrefs.  The list included in the above code doesn't really hinder anything but still requires me to update or modify when engineers are added or subtracted from the company.  Of course, there are many others who are obtaining their P.E. license so modifications are imminent.  Thanks for the cleanup, btw.  Less is more.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...