crgonzo Posted January 24, 2023 Posted January 24, 2023 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 Quote
mhupp Posted January 24, 2023 Posted January 24, 2023 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) ) ) ) Quote
crgonzo Posted January 24, 2023 Author Posted January 24, 2023 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. Quote
crgonzo Posted January 24, 2023 Author Posted January 24, 2023 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 Quote
crgonzo Posted January 24, 2023 Author Posted January 24, 2023 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) Quote
mhupp Posted January 24, 2023 Posted January 24, 2023 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) 1 Quote
mhupp Posted January 24, 2023 Posted January 24, 2023 (edited) 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 January 24, 2023 by mhupp Quote
Steven P Posted January 25, 2023 Posted January 25, 2023 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.... Quote
mhupp Posted January 25, 2023 Posted January 25, 2023 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")) Quote
Steven P Posted January 25, 2023 Posted January 25, 2023 30 minutes ago, mhupp said: In their first post (command "script" "C:\\crg\\Scripts\\badseal-unload.scr")) Ahh, yes. Quote
crgonzo Posted January 25, 2023 Author Posted January 25, 2023 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. Quote
Recommended Posts
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.