Lee Mac Posted December 12, 2008 Posted December 12, 2008 Ahh, the simple way - much easier than what I have posted - I'm not sure why I have to make things harder for myself by going into the DXF unnecesarily... oh well. But what I might add is that your LISP doesn't account for if the layer that you are moving the entities to doesn't exist.... Quote
Lee Mac Posted December 12, 2008 Posted December 12, 2008 EDIT: Posted LISP altered to include auto-run (c:cleanup) Quote
StevJ Posted December 12, 2008 Posted December 12, 2008 Lee Mac, That Layer Director that you posted works great, but it seems to only work for built-in Autocad commands, because I can't seem to get it to work with any custom LISP commands. Does a custom LISP command have to be specially stated in your program? The routine TOP.LSP is loaded: (defun C:TOP() (load "C:/STEVE/ACADSTUFFS/LISP/AUTOLISP/TOP") (C:TOP)) ((= thecommandstart "TOP") (setvar "clayer" "NOPLOT") ) ; end condition 3 When the TOP command is used, via custom button, I'm trying to have it do its thing on the NOPLOT layer, which already exists. I could simply add to the button command to make NOPLOT the current layer, but I really like the way your program returns to whatever layer was current. Do you have any suggestions? Thanks, Steve ACAD 2006 Quote
Lee Mac Posted December 13, 2008 Posted December 13, 2008 Hi Steve, Thank you for your post. I must admit, I am not completely knowledgeable in the reactor side of LISP, and I only learnt how to make that posted LISP from a tutorial on AfraLISP. I can't see why the LISP wouldn't work for a loaded LISP, but then I have not tried it and wouldn't be able to tell you what to do if it didn't. Perhaps someone else here more knowledgeable can lend a hand. Quote
Lee Mac Posted December 13, 2008 Posted December 13, 2008 See here for the tutorial on Reactors - you may find some info: Reactors Hope this Helps Quote
arjun_samar Posted December 14, 2008 Posted December 14, 2008 big bros..... whooo..... what are you guys talking bout' ??? SOOrrryyy im really new to acad.... just wondering.. that ACADDOC.LSP that sounds like pretty cool.. just wondering what does it do? thanks so much in advance big Bros.... arjun-student Quote
Lee Mac Posted December 14, 2008 Posted December 14, 2008 Hey mate, the acaddoc.lsp file gets loaded everytime ACAD is started, and so one can modify it to include calls to custom LISP files to load these custom files also. This thread is asking what modifications people would usually add to the acaddoc.lsp file. Quote
arjun_samar Posted December 14, 2008 Posted December 14, 2008 Hey mate, the acaddoc.lsp file gets loaded everytime ACAD is started, and so one can modify it to include calls to custom LISP files to load these custom files also. This thread is asking what modifications people would usually add to the acaddoc.lsp file. What does it really do big bro? I just really quite don't understand Cad LISP... are there any tutor about this topic big bro? thanksss. Quote
Lee Mac Posted December 14, 2008 Posted December 14, 2008 Well, everyone around here mostly uses AfraLISP (just google it). It a good website for tutorials on everything to do with LISP. Quote
feargt Posted December 14, 2008 Author Posted December 14, 2008 Ahh, the simple way - much easier than what I have posted - I'm not sure why I have to make things harder for myself by going into the DXF unnecesarily... oh well. But what I might add is that your LISP doesn't account for if the layer that you are moving the entities to doesn't exist.... All are drawings are started using a template drawing with all layers etc set up. But it may be worth it in the long run to account for this event. will have a think about it. Quote
Lee Mac Posted December 14, 2008 Posted December 14, 2008 Sure, gd point, I use a template too - but it makes no odds to add this line: (if (not (tblsearch "layer" "Layerx")) (command "-layer" "m" "Layerx" "") ) Quote
feargt Posted December 14, 2008 Author Posted December 14, 2008 This will scoop up Blocks & Xrefs: (defun c:cleanup (/ *error* varLst oldVars ss ssl index ent) ; --- Error Trap --- (defun *error* (msg) (mapcar 'setvar varLst oldVars) (if (= msg "") (princ "\nDrawing Cleaned.") (princ "\nError or Esc pressed... ") ) ;_ end if (princ) ) ; end of *error* (setq varLst (list "CMDECHO" "CLAYER") oldVars (mapcar 'getvar varLst) ) ; end setq ; --- Error Trap --- (setq ss (ssget "X" (list (cons 0 "INSERT")))) (setq ssl (sslength ss) index 0 ) ;_ end setq (setvar "cmdecho" 0) (makelay "BLOCKS & XREFS") (repeat ssl (setq ent (entget (ssname ss index))) (setq ent (subst (cons 8 "BLOCKS & XREFS") (assoc 8 ent) ent)) (entmod ent) (setq index (+ index 1)) ) ;_ end repeat (*error* "") (princ) ) ;_ end defun (defun makelay (x) (if (not (tblsearch "Layer" x)) (command "-layer" "m" x "") ) ;_ end if ) ;_ end defun (c:cleanup) Am still having problems trying to select just xrefs, is possible to modify this code just to sweep up xrefs and leave blocks alone?? Quote
Lee Mac Posted December 14, 2008 Posted December 14, 2008 Without using Active X methods, (which I really need to learn more about), one needs to find somedifference in the DXF table of a generic block and an xref, and then use this in the LISP to sift out the Xrefs. Quote
Lee Mac Posted December 14, 2008 Posted December 14, 2008 After experimenting with the xref and block DXF tables, I see no difference, so this could be a problem better solved with Active X methods. Quote
Lee Mac Posted December 14, 2008 Posted December 14, 2008 I put this together from a LISP I found on the net - (untested): (defun c:cleanup (/ *error* varLst oldVars ss ssl index ent) ; --- Error Trap --- (defun *error* (msg) (mapcar 'setvar varLst oldVars) (if (= msg "") (princ "\nDrawing Cleaned.") (princ "\nError or Esc pressed... ") ) ;_ end if (princ) ) ; end of *error* (setq varLst (list "CMDECHO" "CLAYER") oldVars (mapcar 'getvar varLst) ) ; end setq ; --- Error Trap --- ; Xref Selection, Credit to Aaron Lance (defun xrefsel (/ blk xrefs) (setq blk (tblnext "BLOCK" 'T)) (while blk (if (> (logand 4 (cdr (assoc 70 blk))) 0) (progn (setq name (cdr (assoc 2 blk))) (setq xrefs (if xrefs (strcat xrefs "," name) name ) ;_ end if ) ;_ end setq ) ;_ end progn ) ;_ end if (setq blk (tblnext "BLOCK")) ) ;_ end while (ssget "X" (list '(0 . "INSERT") (cons 2 xrefs))) ) ;_ end defun ;------------------- (setq ss (xrefsel)) (setq ssl (sslength ss) index 0 ) ;_ end setq (setvar "cmdecho" 0) (makelay "XREFS") (repeat ssl (setq ent (entget (ssname ss index))) (setq ent (subst (cons 8 "XREFS") (assoc 8 ent) ent)) (entmod ent) (setq index (+ index 1)) ) ;_ end repeat (*error* "") (princ) ) ;_ end defun (defun makelay (x) (if (not (tblsearch "Layer" x)) (command "-layer" "m" x "") ) ;_ end if ) ;_ end defun (c:cleanup) Quote
feargt Posted December 15, 2008 Author Posted December 15, 2008 I put this together from a LISP I found on the net - (untested): (defun c:cleanup (/ *error* varLst oldVars ss ssl index ent) ; --- Error Trap --- (defun *error* (msg) (mapcar 'setvar varLst oldVars) (if (= msg "") (princ "\nDrawing Cleaned.") (princ "\nError or Esc pressed... ") ) ;_ end if (princ) ) ; end of *error* (setq varLst (list "CMDECHO" "CLAYER") oldVars (mapcar 'getvar varLst) ) ; end setq ; --- Error Trap --- ; Xref Selection, Credit to Aaron Lance (defun xrefsel (/ blk xrefs) (setq blk (tblnext "BLOCK" 'T)) (while blk (if (> (logand 4 (cdr (assoc 70 blk))) 0) (progn (setq name (cdr (assoc 2 blk))) (setq xrefs (if xrefs (strcat xrefs "," name) name ) ;_ end if ) ;_ end setq ) ;_ end progn ) ;_ end if (setq blk (tblnext "BLOCK")) ) ;_ end while (ssget "X" (list '(0 . "INSERT") (cons 2 xrefs))) ) ;_ end defun ;------------------- (setq ss (xrefsel)) (setq ssl (sslength ss) index 0 ) ;_ end setq (setvar "cmdecho" 0) (makelay "XREFS") (repeat ssl (setq ent (entget (ssname ss index))) (setq ent (subst (cons 8 "XREFS") (assoc 8 ent) ent)) (entmod ent) (setq index (+ index 1)) ) ;_ end repeat (*error* "") (princ) ) ;_ end defun (defun makelay (x) (if (not (tblsearch "Layer" x)) (command "-layer" "m" x "") ) ;_ end if ) ;_ end defun (c:cleanup) Thanks for taking interest in that one! That seems to do the trick, if I have any issues with it I will let you know in case anyone else looks for something similar!! Quote
Lee Mac Posted December 15, 2008 Posted December 15, 2008 No probs feargt, glad it worked out for you Quote
ReMark Posted December 16, 2008 Posted December 16, 2008 "What modifications people would usually add to the acaddoc.lsp file?" I add just one line that calls an enhanced version of the acad LISP file for the AutoCAD version I'm currently running. This enhanced file contains all of my custom LISP routines. Quote
Lee Mac Posted December 16, 2008 Posted December 16, 2008 Thats, quite a good idea, I suppose it means less modification is needed to the actual ACADDOC.lsp file. 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.