Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

My ACAD.LSP file 5

Status
Not open for further replies.

Sparweb

Aerospace
May 21, 2003
5,109
I felt like sharing today.

Code:
;	Extra commands for AutoCAD
;	Steven Fahey
;	7 JANUARY 2015
;

(defun c:VRA    () (command "view" "r" "A"))
(defun c:VRB    () (command "view" "r" "B"))
(defun c:VRC    () (command "view" "r" "C"))
(defun c:VRD    () (command "view" "r" "D"))
(defun c:VRE    () (command "view" "r" "E"))
(defun c:VRF    () (command "view" "r" "F"))

(defun c:VSA    () (command "view" "s" "A"))
(defun c:VSB    () (command "view" "s" "B"))
(defun c:VSC    () (command "view" "s" "C"))
(defun c:VSD    () (command "view" "s" "D"))
(defun c:VSE    () (command "view" "s" "E"))
(defun c:VSF    () (command "view" "s" "F"))

(defun c:ZA     () (command "zoom" "all"))
(defun c:ZE     () (command "zoom" "e"))
(defun c:ZP     () (command "zoom" "previous"))
(defun c:ZI     () (command "zoom" "2x"))
(defun c:ZO     () (command "zoom" ".8x"))
(defun c:ZOO    () (command "zoom" ".5x"))
(defun c:Z1P    () (command "zoom" "1xp"))

(defun c:BRA    () (command "break" pause "f" "int" pause "@"))

(defun c:U1     () (command "luprec" "1"))
(defun c:U2     () (command "luprec" "2"))
(defun c:U3     () (command "luprec" "3"))
(defun c:U4     () (command "luprec" "4"))
(defun c:U5     () (command "luprec" "5"))

(defun c:cttr   () (command "circle" "ttr" "tan" pause "tan"))
(defun c:c3p    () (command "circle" "3p"))
(defun c:c2p    () (command "circle" "2p"))

(defun c:filt   () (command "fillet" "trim" "t"))
(defun c:filn   () (command "fillet" "trim" "n"))

(defun c:xv     () (command "xline" "v"))
(defun c:xh     () (command "xline" "h"))

(defun c:purgall () (command "purge" "a" "" "n"))

(defun c:coro   () (command "copy" pause "" "0,0" "@" "rotate" "p" "" pause "90"))

(defun c:bam    () (command "base" "0,0,0" "move" "all" "" pause "0,0,0" "zoom" "e" "zoom" "0.75x"))

AutoCAD is designed to be used with a keyboard. Users who don't maximize their use of a keyboard are not maximizing their efficiency in AutoCAD.

Here is an explanation of the keyboard shortcuts I like:

I make multi-sheet drawings. Saved views allow me to switch easily from one sheet to another. VRA jumps to sheet A, no matter where I started from.
I dodn't always have a scroll wheel mouse, eg Laptop trackpad. ZI and ZO allow quick zooming in without selecing windows over and over.
I still frequently use ZE to see EVERYTHING - and find all the stuff people drew 6 miles to the left of the main view.
Breaking lines takes a lot of clicks. BRA saves clicks.
Many users don't configure units, and I may open their drawing to find either 10 decimal places, or none. U1 through U5 saves many clicks.
Making Circles requires more clicks than necessary.
I don't do Filleting without trimming very often, but when I do I want to switch back and forth frequently during the process, so this helps.
Construction lines are valuable so I shortened the typing to have horizontal and vertical XLINES.
Making drawings inevitably means bringing in blocks, styles, and "stuff" you don't need when you're done. Purgall in one command dumps all the chaff.
How often do you want a copy of a line rotated 90 degrees? Do both steps in one CORO.
Did you create a block file, but set its base in the wrong spot? BAM and you're done. It even resizes the view to fit the preview.


STF
 
Replies continue below

Recommended for you

I gave you a star and didn't post anything... I should have left a message, sorry. I've incorporated a couple of your commands into my own CAD set up; thanks very much.

Dik
 
Thanks.
Hopefully others will share, too....

STF
 
Your effort is appreciated...

Dik
 
The time has came that Autocad is usable less and less.
Some time ago I had really big library of additional Autocad functions in Lisp. But with every new Autocad version came new functions together. So some Lisp text were going to oblivion.
Still using several Lisp commands saved in my acad.lsp

Often I need to break element from first point like SparWeb has (BRA):
(defun c:BRF()
(command "BREAK" pause "F" (setq f_point (getpoint)) f_point)
(princ)
)


Sometimes draw a line between to arcs from tangent to tangent:
(defun c:LTT ()
(command "line" "tan" pause "tan" pause "")
)


Occasionally I draw a circles with given arc length:
(defun c:CBL()
(setq cp (getpoint "\nCenter of the circle: ")
cl (getdist "\nLength of the cirle: ")
)
(setq rad (/ cl (* pi 2)))
(command "CIRCLE" cp rad)
)


Sometimes I have to measure distance in XY plane with Z distance ignored:
(defun c:DIXY ( / fPoint sPoint XYDist)
(setq fPoint (getpoint "\nSelect the first point of XY distance: ")
sPoint (getpoint fPoint "\nSelect the second point of XY distance: ")
XYDist (distance (list (car fPoint) (cadr fPoint) 0.0) (list (car sPoint) (cadr sPoint) 0.0))
)
(princ (strcat "\n\nDISTANCE on XY plane = " (rtos XYDist)))
(princ)
)
 
I know I'll use LTT. Thanks!

STF
 
I've not written any lisp programs for simplifying commands and am already using 3 of Sparwebs... the LTT looks useful. Should have added... works well with Bricscad.

[Added] forgot to mention file name for Bricscad is On_Start.lsp, your CAD program may use something other than acad.lsp. Check the directory that your CAD app is installed in and do a search for *.lsp. You may be able to determine which one loads.

Dik
 
maripali said:
The time has came that Autocad is usable less and less.

In some ways, this is inevitable when AutoCAD remains essentially the same tool, and other tools become so capable at doing similar or competing things.
So IMO it's just AutoCAD standing still while the others run ahead.

On the other hand, Autodesk's attempts to make AutoCAD more "user-friendly" have severely affected a user's ability to learn and appreciate all of its capabilities. Many of my co-workers have AutoCAD but know nothing of its abilities. They say it "can't be done" or "that's really hard" when I know I can do it in a snap in AutoCAD. ISO views, tracing photographs and fastener patterns from paper rubbings, and so much more. 3D parametric CAD can't do that. I have accepted that from now on, people who think they can't do such things will be the norm, and that their biggest obstacle will be looking down their noses at AutoCAD. Knowing what they refuse to know gives me a competitive advantage over my co-workers, so I won't shed a tear as they disappear behind me.


STF
 
I agreed with you SparWeb. In my life I meet many people from manufacturing and engineering plant that "work" with Autocad for centuries and well knows how to open drawing, print it and as higher level users are able to put some dimensions.

Autocad still always by my hand, just time I spend with it become shorten.
 
Thank you Spar.


Although some time ago I tried to find my ACAD.LSP file without success, I appreciate what you shared

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"
 
"tried to find my ACAD.LSP file without success"
Download and install "Everything" from VoidTools.com
 
(DEFUN C:BR2 () (COMMAND "BREAK" PAUSE "F" PAUSE "@0,0" ) (PRINC)) ; Break at a single point
(DEFUN C:DAS () (COMMAND "DIMREASSOCIATE"))
(DEFUN C:MT () ; MText on layer TEXT
(setq CLA (getvar "CLayer"))
(progn
(setvar "CLayer" "TEXT")
(command "MTEXT" pause "J" "bl" pause)
(setvar "Clayer" CLA)
)
(PRINC)
)

etc etc etc
 
IFRs said:
Download and install "Everything" from VoidTools.com

Thanks for the advice. I've tried and still can not find "ACAD.LSP". Is it possible that it does not exist in my PC?

Thank you!

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"
 
And, at the top of my Acad.lsp file is the following, that at one time inserted to redefine my titleblock and now occasionally is temporarily added to for short term things (like turn all SPlines to RED):

(DEFUN S::Startup ()
; (command "insert" "title=title" "y" "0,0" "1" "1" "0" "" "" "" "" "" "" "" "")
; (command "zoom" "e")
; (command "erase" "l" "")
; (command "layer" "freeze" "rev*" "")
(setvar "modemacro"
(strcat
"$(getvar,clayer)"
"$(getvar,dimstyle)"
"$(if,$(getvar,orthomode), ORTHO)"
"$(if,$(=,$(getvar,osmode),0), NON)"
"$(if,$(=,$(getvar,osmode),1), END)"
"$(if,$(=,$(getvar,osmode),2), MID)"
"$(if,$(=,$(getvar,osmode),4), CEN)"
"$(if,$(=,$(getvar,osmode),8), NOD)"
"$(if,$(=,$(getvar,osmode),16), QUA)"
"$(if,$(=,$(getvar,osmode),32), INT)"
"$(if,$(=,$(getvar,osmode),64), INS)"
"$(if,$(=,$(getvar,osmode),128), PER)"
"$(if,$(=,$(getvar,osmode),256), TAN)"
; "$(getvar,dwgname)"
)
)
(princ)
)
 
Create your own using Notepad or other pure ASCII text editor
Put it in your support file path
 
LOL, I think i've found it.

Mine is called acad2014.lsp

There is also another file called acad2014doc.lsp that is full of commands; I think I just need to edit acad2014.lsp, am I right?

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"
 
IFRS said:
"tried to find my ACAD.LSP file without success"

Way back when... I did a search of my C: drive (OS and application drive)... it's actually a M.2 drive, and did a search for *.lsp files... Bricscad uses a startup file called on_start.lsp and not acad.lsp that it loads first. You may have a similar equivalent file.

In an earlier posting I noted that I upgraded to include a couple of the lisp files and forgot to mention that it was a different file name than acad.lsp, I just did it without thinking about it; I updated the on_start.lsp and should have mentioned it was a filename different than acad.lsp.

Dik
 
IFRS said:
Create your own using Notepad or other pure ASCII text editor

Another really good addition equivalent to Notepad on steroids... Notepad ++ Look it up, you'll like it.

Dik
 
JuanBC,
I don't think the files you found are the right ones... hard to tell. You haven't told us what version of the software you have.
Over the years, and depending on the version of AutoCAD and maybe also system OS and user/administrator setup, Autodesk installs AutoCAD in slightly different ways. It takes some hunting. Here are the places where I have found my Support path:

(years ago) C:\Users\Rigel\AppData\Roaming\Autodesk\AutoCAD 2009\R17.2\enu\Support
(recently) C:\Program Files\Autodesk\AutoCAD 2017\Support

You will find a basic "acad.lsp" there. You can add new LISP routines in the file by editing with a text editor like Notepad (Notepad++ is better).

I have kept my own personal .LSP file (and .PGP, .LIN files, too) in a separate location so that I can reinstall them every year I upgrade.

STF
 
Hi Spar,

I am using Autocad 2014 and I found acad2014.lsp on C:\Appls\Autodesk\AutoCAD 2014\Support

This is what it got:

Code:
; MODULE_ID ACAD2007_LSP_
;;;    ACAD2014.LSP Version 1.0 for AutoCAD 2014
;;;
;;;  Copyright 2013 Autodesk, Inc.  All rights reserved.
;;;
;;;  Use of this software is subject to the terms of the Autodesk license 
;;;  agreement provided at the time of installation or download, or which 
;;;  otherwise accompanies this software in either electronic or hard copy form.
;;;
;;;
;;;
;;;    Note:
;;;            This file is normally loaded only once per AutoCAD session.
;;;            If you wish to have LISP code loaded into every document,
;;;            you should add your code to acaddoc.lsp.
;;;
;;;    Globalization Note:   
;;;            We do not support autoloading applications by the native 
;;;            language command call (e.g. with the leading underscore
;;;            mechanism.)

(if (not (=  (substr (ver) 1 11) "Visual LISP")) (load "acad2014doc.lsp"))

;; Silent load.
(princ)

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor