Jump to content

Recommended Posts

Posted

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....

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    20

  • feargt

    9

  • ASMI

    2

  • GhostRider

    2

Posted

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

Posted

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. :oops:

 

Perhaps someone else here more knowledgeable can lend a hand. :D

Posted

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

Posted

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. :D

Posted
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. :D

 

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.

Posted

Well, everyone around here mostly uses AfraLISP (just google it). It a good website for tutorials on everything to do with LISP.

Posted
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.

Posted

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" "")
)

Posted
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??

Posted

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.

Posted

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. :?

Posted

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)

Posted
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!!

Posted

"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.

Posted

Thats, quite a good idea, I suppose it means less modification is needed to the actual ACADDOC.lsp file.

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...