au-s Posted March 10, 2009 Posted March 10, 2009 Hi, I need a lisp to attach xref only in pscape... Will not work in modelspace... I cant get it right ... Here is my code ... Can someone check it... Thanx fellers .. (Defun checkxref () (if (tblsearch "layer" "P-------XREF") (command "_layer" "s" "P-------XREF" "") (command "_layer" "m" "P-------XREF" "c" "7" "" "lo" "P-------XREF" "" ) ) ) (defun c:pscpace (/ dfil oldlay) (setq oldlay (getvar "clayer")) (IF (= (getvar "tilemode") 1) (setvar "tilemode" 0) ) (checkxref) (setq dfil (dos_getfiled "choose file:" "" "Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||")) (if (= dfil 6) (progn (command "_xref" "o" dfil "0,0" "1" "1" "0" "") (setvar "clayer" oldlay) ))(alert "Only possible in PSPACE") ) Quote
Tiger Posted March 10, 2009 Posted March 10, 2009 don't know anything about lisps but can I just ask, why do you need it? Quote
au-s Posted March 10, 2009 Author Posted March 10, 2009 Because in the office of more than 100 I need to: 1. Get xref in one specific layer 2. Get the xref locked 3. Always be sure of that it have insertion point 0,0 4. It ALWAY comes in Ocverlay Among other things. .. These parameters which are pretty obvious are sometimes not used. And I want a routine to "lock" certain things that I cannot achieve with XATTACH Quote
Tiger Posted March 10, 2009 Posted March 10, 2009 So it's a matter of doing a fool-proof system of inserting a x-ref that not even Mr Magoo can mess up - gotcha :wink: Quote
au-s Posted March 10, 2009 Author Posted March 10, 2009 Yepp! There are some 55+ aged here and those employees are not funny at all. So .. can anyone take a look at this lisp? Quote
Hardeight Posted March 10, 2009 Posted March 10, 2009 well I was going to try and help but I crash everytime I get to DOS_GETFILED, ; error: no function definition: DOS_GETFILED Looks like I have stumbled onto a problem I need to investigate..... Quote
Se7en Posted March 10, 2009 Posted March 10, 2009 I think that was apart of doslib. *thought* you can use "getfiled" (getfiled (strcat "File not found") "" "dwg" 2) Quote
Hardeight Posted March 10, 2009 Posted March 10, 2009 OK, I figured out my problem and I found yours too, I think. The problem is with your "if" statement. You are asking if the selected drawing (dfil) is equal to the integer 6. I would imagine this would never happen. If you want to make sure they are selecting one certain file everytime you need to change your equality to something like "C:\\Documents and Settings\\etc. etc... \\standardxref.dwg" or if there are multiple possibilities, do a cond statement with all the possibilities. Hope this gets you on the right track. Quote
Se7en Posted March 10, 2009 Posted March 10, 2009 OK, I figured out my problem and I found yours too, I think.The problem is with your "if" statement. You are asking if the selected drawing (dfil) is equal to the integer 6. I would imagine this would never happen. If you want to make sure they are selecting one certain file everytime you need to change your equality to something like "C:\\Documents and Settings\\etc. etc... \\standardxref.dwg" or if there are multiple possibilities, do a cond statement with all the possibilities. Hope this gets you on the right track. No the predicate is: to see if the variable evaluates to the `correct' return from the function ``dos_getfiled'' -i.e. does the variable evaluate eq to 6. I dont have dos lib so i dont know that function or its return values. If all you want to do is to check to see if a drawing is referenced into the current drawing wouldn't a simple series of tests be easier? Something like (of course this is only an example): ( (lambda (/ entry xname) (setq xname "Drawing1") (while ;; itterate thru all xrefs in dwg (setq entry (tblnext "block" (not entry))) ;; get the first block (if (cdr (assoc 1 entry)) ;; check to see if it has a path (is an xref) ;; ;; if it does.. (if (eq (cdr (assoc 2 entry)) xname) (if (zerop (logand (cdr (assoc 70 entry)) 32)) (princ (strcat "\n" xname " is referenced but is unloaded!")) (princ (strcat "\n" xname " is referenced and loaded")) ) (princ (strcat "\n" xname " has NOT been referenced into this drawing"))))) (princ)) ) Quote
au-s Posted March 10, 2009 Author Posted March 10, 2009 hello fellers... here is the solution I made .. You need DOSlib to get it to work ... Enjoy ... got help from another Forum!!! (Defun checkxref () (if (tblsearch "layer" "P-------XREF") (command "_layer" "s" "P-------XREF" "") (command "_layer" "m" "P-------XREF" "c" "7" "" "lo" "P-------XREF" "" ) ) ) (defun c:pscpace (/ dfil oldlay) (setq oldlay (getvar "clayer")) (setvar "cmdecho" 0) (IF (= (getvar "tilemode") 0) (progn (checkxref) (setq dfil (dos_getfiled "choose file:" "" "Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||")) (if (= dfil 6) (setvar "filedia" 0) (command "_xref" "o" dfil "0,0" "1" "1" "0") ) ) (alert "Only possible in PSPACE"))(setvar "clayer" oldlay)(setvar "filedia" 1) ) the only problem I got is that in the end of the command when xref is attached .. I get on the command line: 1. I think it might be something with the filedia variable? Not sure here .... 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.