Jump to content

Recommended Posts

Posted

Hi,

 

I am looking for some feedback on the use of acaddoc.lsp file

 

I am looking for ideas that I may be missing that would be worth putting into my acaddoc.lsp file.

 

If you have edited your acaddoc.lsp file to do several things to a drawing each time you open one, what does YOUR acaddoc.lsp file do for you?

 

looking forward to any comments.

 

Thanks in advance

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    20

  • feargt

    9

  • ASMI

    2

  • GhostRider

    2

Posted

I actually use ACAD.LSP in a folder stored in the search path for customizations and it contains 100's of nice little shortcuts and to load all the supporting lisps I use and things that I would be lost without anymore...

There may be better or easier ways but this works well for me.

 

Here's a few of my fav's

layer quick keys to set layerstates with short keystrokes

 

(DEFUN C:LT ()
 (COMMAND "-LAYER" "T" "*" "") (PRINC))

some quick command strokes like this

(defun C:DD () (COMMAND "DIMLINEAR") (PRINC))
(defun C:DF () (COMMAND "DIMBASELINE") (PRINC))
(defun C:AD () (command "DIMANGULAR") (PRINC))
(defun C:DA () (command "DIMALIGNED") (PRINC))
(defun C:F6 () (COMMAND "FILLET" "R" "6") (COMMAND "FILLET") (PRINC))
(defun C:F0 () (COMMAND "FILLET" "R" "0") (COMMAND "FILLET") (PRINC))
(defun C:F8 () (COMMAND "FILLET" "R" "8") (COMMAND "FILLET") (PRINC))
(defun C:F3 () (COMMAND "FILLET" "R" "3") (COMMAND "FILLET") (PRINC))
(defun C:dc () (COMMAND "_dimcontinue" pause) (princ))

 

offset shortcuts

 

(defun c:2- () (command "OFFSET" "2") (princ))
(defun c:2-5 () (command "OFFSET" "2.5") (princ))
(defun c:3- () (command "OFFSET" "3") (princ))
(defun c:3-5 () (command "OFFSET" "3.5") (princ))
(defun c:4- () (command "OFFSET" "4") (princ))
(defun c:4-5 () (command "OFFSET" "4.5") (princ))
(defun c:5- () (command "OFFSET" "5") (princ))
(defun c:5-5 () (command "OFFSET" "5.5") (princ))
(defun c:6- () (command "OFFSET" "6") (princ))
(defun c:6-5 () (command "OFFSET" "6.5") (princ))

 

a nice little lisp to join polylines easily from lpseifert here on cadtutor

 

;====ADDED 10-8-08 JOIN LINES/POLYLINES POLY
(defun c:pj ()
 (setq pa (getvar "peditaccept"))
 (setvar "peditaccept" 1)
   (setq ssj (ssget))
   (command "pedit" "m" ssj ""  "j" "0.01" "")
 (setvar "peditaccept" pa)
(princ)
)

 

possibilities are endless.... sure saves me alot of time though,... except I forget all the shortcut commands I have added over the years and have to open the txt file to browse it sometimes.....

Posted

One really useful LISP that I use was made from a tutorial on good ol' AfraLISP - a reactor that automatically sets my layers to what I am doing - so that everything is always on the correct layers:

 

; Layer Director

(vl-load-com)

(vlr-command-reactor
   nil '((:vlr-commandWillstart . startCommand))
) ; end command reactor
(vlr-command-reactor
   nil '((:vlr-commandEnded . endcommand))
) ; end command reactor
(vlr-command-reactor
   nil '((:vlr-commandCancelled . cancelCommand))
) ; end command reactor

(defun startCommand (calling-reactor startcommandInfo / thecommandstart)
   (setq oldlay (getvar "clayer"))
   (setq thecommandstart (nth 0 startcommandInfo))
   (cond
       ((= thecommandstart "TEXT")
        (setvar "clayer" "TEXT")
       ) ; end condition 1
       ((= thecommandstart "MTEXT")
        (setvar "clayer" "TEXT")
       ) ; end condition 2
       ((= thecommandstart "DTEXT")
        (setvar "clayer" "TEXT")
       ) ; end condition 3

;        ---------------------------

       ((= thecommandstart "DIMLINEAR")
        (setvar "clayer" "DIM")
       ) ; end condition 4
       ((= thecommandstart "DIMALIGNED")
        (setvar "clayer" "DIM")
       ) ; end condition 5
       ((= thecommandstart "DIMRADIUS")
        (setvar "clayer" "DIM")
       ) ; end condition 6
       ((= thecommandstart "DIMDIAMETER")
        (setvar "clayer" "DIM")
       ) ; end condition 7
       ((= thecommandstart "DIMANGULAR")
        (setvar "clayer" "DIM")
       ) ; end condition 8
       ((= thecommandstart "DIMORDINATE")
        (setvar "clayer" "DIM")
       ) ; end condition 9

;        ---------------------------

       ((= thecommandstart "+VPORTS")
        (setvar "clayer" "DEFPOINTS")
       ) ; end condition 10
   ) ; end cond
   (princ)
) ; end startcommand

(defun endCommand (calling-reactor endcommandInfo / thecommandend)
   (setq thecommandend (nth 0 endcommandInfo))
   (cond
       ((= thecommandend "TEXT")
        (setvar "clayer" oldlay)
       ) ; end condition 1
       ((= thecommandend "MTEXT")
        (setvar "clayer" oldlay)
       ) ; end condition 2
       ((= thecommandend "DTEXT")
        (setvar "clayer" oldlay)
       ) ; end condition 3

;        ---------------------------

       ((= thecommandend "DIMLINEAR")
        (setvar "clayer" oldlay)
       ) ; end condition 4
       ((= thecommandend "DIMALIGNED")
        (setvar "clayer" oldlay)
       ) ; end condition 5
       ((= thecommandend "DIMRADIUS")
        (setvar "clayer" oldlay)
       ) ; end condition 6
       ((= thecommandend "DIMDIAMETER")
        (setvar "clayer" oldlay)
       ) ; end condition 7
       ((= thecommandend "DIMANGULAR")
        (setvar "clayer" oldlay)
       ) ; end condition 8
       ((= thecommandend "DIMORDINATE")
        (setvar "clayer" oldlay)
       ) ; end condition 9

;        ---------------------------

       ((= thecommandend "+VPORTS")
        (setvar "clayer" oldlay)
       ) ; end condition 10

   ) ; end cond
   (princ)
) ; end endCommand

(defun cancelCommand (calling-reactor cancelcommandInfo / thecommandcancel)
   (setq thecommandcancel (nth 0 cancelcommandInfo))
   (cond
       ((= thecommandcancel "TEXT")
        (setvar "clayer" oldlay)
       ) ; end condition 1
       ((= thecommandcancel "MTEXT")
        (setvar "clayer" oldlay)
       ) ; end condition 2
       ((= thecommandcancel "DTEXT")
        (setvar "clayer" oldlay)
       ) ; end condition 3

;        ---------------------------

       ((= thecommandcancel "DIMLINEAR")
        (setvar "clayer" oldlay)
       ) ; end condition 4
       ((= thecommandcancel "DIMALIGNED")
        (setvar "clayer" oldlay)
       ) ; end condition 5
       ((= thecommandcancel "DIMRADIUS")
        (setvar "clayer" oldlay)
       ) ; end condition 6
       ((= thecommandcancel "DIMDIAMETER")
        (setvar "clayer" oldlay)
       ) ; end condition 7
       ((= thecommandcancel "DIMANGULAR")
        (setvar "clayer" oldlay)
       ) ; end condition 8
       ((= thecommandcancel "DIMORDINATE")
        (setvar "clayer" oldlay)
       ) ; end condition 9

;        ---------------------------

       ((= thecommandcancel "+VPORTS")
        (setvar "clayer" oldlay)
       ) ; end condition 10

   ) ; end cond
   (princ)
) ; end cancelCommand

 

Really useful if you have new people in the company who don't know your layer structure yet...

Posted

Lee Mac, what exactly does that do, looking at it it looks like a command like "TEXT" sets the current layer to the TEXT layer. is that correct?

 

I think I've turned into a lisp junkie but I still don't understand it all ......

Posted

sorry to kind of hijack the thread, but rather than ask for virtually what is above in a new thread ill ask here: Lee Mac, that looks close to what im looking for, what i need is that when i insert all dimensions they go on the dimensions layer, Text on text layer, Hatch on hatch layer. Your's doesnt seem to have hatch. Ive played around with tool palettes but the biggest problem with them is i already have all my macro buttons and toolbars, i dont want another thing clogging up my screen. And the tool palettes dont have everything i need - ie: open, save, print. Can anyone help with that?

Posted

Hi Guys,

 

The posted LISP is a reactor, which means that you don't have to type a syntax to run it - you just load it on start-up and it will perform as required.

 

It can be easily modified to suit your needs:

 

Just add a new line to each section i.e.:

 


((= thecommandstart "HATCH")
        (setvar "clayer" "HATCH")
       ) ; end condition 1

 

This in the first "cond" section, to react whenever the "hatch" command is started.

 

But one must also consider what happens when the command exits or the user hits escape during the command, so the following lines also need to be added:

 


((= thecommandend "HATCH")
        (setvar "clayer" oldlay)
       ) ; end condition 1

 

And for an escape:

 


((= thecommandcancel "HATCH")
        (setvar "clayer" oldlay)
       ) ; end condition 1

 

Both of the above installments will reset the layer back to the original layer

 

If you look closely at the LISP itself, it is obvious where these code section fit.

 

But if you have any further queries let me know. :)

 

EDIT:

 

Just looking back at the example I displayed - it does assume that there exists a layer named "HATCH".

 

But add this somewhere in the LISP to overcome it:

 

(if     (not (tblsearch "Layer" "HATCH"))
   (vl-cmdf "-layer" "m" "HATCH" "")
)

Posted

Thanks for all the comments AND for including code too, was not expecting that.

 

Lee Mac, using the reactor can I assume that would work for xref's too? so that on use of xref command the layer would change to say XREF layer. or would that only work if I use the classicxref command??

 

Any other comments and ideas are more than welcome

 

thanks again

Posted

This is my acaddoc.lsp - a few lisps that I use often and a few settings that I can't live without.

 

(load "bo.lsp")

(load "scaleaxis.lsp")

(load "T2M.lsp")

(load "ztext.lsp")

(load "mdi.lsp")

(load "cr.lsp")

(load "crz.lsp")

(load "crf.lsp")

(load "crzf.lsp")

(load "coed.lsp")

(setvar "osmode" 43)

(load "acad.lsp")

(setvar "layereval" 0)

(setvar "layernotify" 0)

Posted

I do not use ACADDOC.LSP, at me it virginily clear. Thus I can carry all my programs and menus on other computer in time of 3 minutes. All of them will be automatically loaded and work.

 

It is an interesting theme, but unfortunately now there is no time to discuss it.

Posted

Lee Mac, using the reactor can I assume that would work for xref's too? so that on use of xref command the layer would change to say XREF layer. or would that only work if I use the classicxref command??

 

To be honest, I haven't tried it - we don't normally include xrefs on a separate layer in our standards, so I haven't had the opportunity to test it.

 

But i would assume it would work - give it a go and let me know :P

 

((= thecommandstart "XREF")
        (setvar "clayer" "XREF")
       ) ; end condition 1

Posted

Don't use the doc.lsp. I load my own custom .mnu and in the mnl. I load all of my customization and other menus. This way it always loads the same on all computers.

Posted
Don't use the doc.lsp. I load my own custom .mnu and in the mnl. I load all of my customization and other menus. This way it always loads the same on all computers.

 

:thumbsup:

 

 

But ACADDOC.LSP sometimes is beautifull thing. For example if you want to install all need programs (lisp, VBA or .NET) in 10 or 1000 computers in one time.

Posted

Don't get me wrong...it is very useful, i just don't use it. My company uses it for batch plotting and thing like that.

Posted
Don't get me wrong...it is very useful, i just don't use it. My company uses it for batch plotting and thing like that.

 

Thanks Tim, the main point of this thread is to see what people put in their acaddoc.lsp or a similar lisp file that they use so as to get an idea of what should be in there, what is helpful and what not.

Posted
To be honest, I haven't tried it - we don't normally include xrefs on a separate layer in our standards, so I haven't had the opportunity to test it.

 

But i would assume it would work - give it a go and let me know :P

 

((= thecommandstart "XREF")
        (setvar "clayer" "XREF")
       ) ; end condition 1

 

I tried that but it did not seem to work, but then the xref command only opend the xref manager, so I tried it using the xattach command which is the command used when actually attaching the xref but unfortunately that did not work either. I reduced what you had posted earlier down to just include for the xref command but did not have any luck.

 

I am a bit surprised that no one seemed to have a drawing clean up function. Whereby when u open an existing drawing it would select all dimensions and put them on the right laxýer, same for text and xrefs etc.

Posted

A drawing clean up function would not be hard to create: just the use of an ssget "X" command on each separate entity and then maybe a (repeat (sslength)) to put it all on the correct layer. Would you like me to put one together?

Posted
A drawing clean up function would not be hard to create: just the use of an ssget "X" command on each separate entity and then maybe a (repeat (sslength)) to put it all on the correct layer. Would you like me to put one together?

 

no need to, have that bit done although I am having a problem with selecting all xrefs in drawing I tried using ssget function with filters. I can't seem to figure out the 2nd filter that I need, I have 0. Block and then I thought 70. 4, don't have it written here as is in work but think it was 70. that i was using for the second filter. I was trying to see how I could do it with activex but the sample code in the autocad help is confusing me a bit.

Posted

Just for a laugh, I thought I'd have a go at making one :P

 

:P *Addicted to LISP* :P

 

(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 "TEXT"))))
   (setq ssl    (sslength ss)
     index    0
   ) ;_  end setq
   (setvar "cmdecho" 0)
   (makelay "TEXT")
   (repeat ssl
   (setq ent (entget (ssname ss index)))
   (setq ent (subst (cons 8 "TEXT") (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)

How does this compare to yours?

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)

Posted (edited)
Just for a laugh, I thought I'd have a go at making one :P

 

:P *Addicted to LISP* :P

 

How does this compare to yours?

 

 

without any error trappings

 

(defun c:drcl ()
(setq ss1 (ssget "X" '((0 . "TEXT")))
)
   (command "_chprop" ss1 "" "la" "text" ""
      )
      (princ)
      )

 

 

l have literally just substituted text for whatever it is that I want to select

Edited by SLW210

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