×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

#### Jobs

2
(OP)
I felt like sharing today.

#### CODE --> LISP

;	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

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

(OP)
Thanks.
Hopefully others will share, too....

STF

Dik

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

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

(OP)
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.

Dik

(OP)

#### Quote (maripali)

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"

(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

#### Quote (IFRs)

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

Put it in your support file path

LOL, I think i've found it.

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"

#### Quote (IFRS)

"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

#### Quote (IFRS)

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

Dik

(OP)
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:

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,

This is what it got:

#### CODE -->

;;;
;;;
;;;  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:
;;;            If you wish to have LISP code loaded into every document,
;;;
;;;    Globalization Note:
;;;            language command call (e.g. with the leading underscore
;;;            mechanism.)

(princ)

Regards

Add to to that one, if it works, great

(OP)

STF

Hello. I copied this on my acad.lsp file and I get an error that says: "; error: AutoCAD variable setting rejected: "CLayer" "TEXT""

#### Quote (IFRs)

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

What am I doing wrong?

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"

Another question:

I've got a bunch of different long lisps in different files (each file, a long command)

Do you think I should "merge" everything on a really long and messy ACAD.LSP or there is a more orderly way of doing it?

I have all my lisps files on my documents folder

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"

To the first JuanBC question:
Before executing (MT) your have to create layer named "TEXT":
Manually in the current drawing.
Manually but once in your drawing template,
or some additional Lisp code where the "TEXT" Layer have to be created if not exists.
Try to put this:

#### CODE -->

(DEFUN C:MT () ; MText on layer TEXT
(setq CLA (getvar "CLayer"))
(progn
(if (not (tblsearch "layer" "TEXT"))
(command "-layer" "m" "TEXT" "c" "80" "" "L" "continuous" "")
)
(setvar "CLayer" "TEXT")
(command "MTEXT" pause "J" "bl" pause)
(setvar "Clayer" CLA)
)
(PRINC)
)

To the second question:

#### CODE -->

Also there in Autocad Options is Startup Suite, where you can set any Lisp file to start in every session.

I usually mash all the smaller ones into Acad.lsp, separated by semi-colons and keep the large ones separate. Makes it easier to edit if needed, for me anyway.

For some that are large but I seldom need I put this in Acad.lsp

(DEFUN C:Cutube () (IF (NOT C:Cutube) (LOAD "Cutube")) (C:Cutube) (PRINC))

Hi maripali,

Thank you for both codes! I really appreciate your help since I'm really noob to ACAD Lisps.

The second code (autoloading lisps) works perfect (using / instead of \), but something went wrong with your MT lisp. This is what I got when I write "MT" on command line:

¿Any ideas? Thank you!

#### CODE --> error

Command: MT
-layer
Current layer:  "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: m
Enter name for new layer (becomes the current layer) <0>: TEXT Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: c
New color [Truecolor/COlorbook] : 80
Enter name list of layer(s) for color 80 <TEXT>: Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: L
Enter loaded linetype name or [?] <Continuous>: continuous
Enter name list of layer(s) for linetype "continuous" <TEXT>: Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: MTEXT
Invalid option keyword.
; error: Function cancelled
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: *Cancel*

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"

Change
(command "-layer" "m" "TEXT" "c" "80" "" "L" "continuous" "")
to
(command "-layer" "m" "TEXT" "c" "80" "" "L" "continuous" "" "")

Thank you! Worked!

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"

JuanBC - the "COMMAND" syntax is exactly what you type on the command line. If you do the -layer command yourself, you will see why the additional "" (representing either a space or return keypress) is needed. Many times this is the key to understanding or making a macro in Acad.lsp. Good luck in future programming!

JaunBC... there are a couple of really good AutoLisp tutorials on the web... if curious, you can look them up... almost a walk through the park...

Dik

#### Quote (dik)

JaunBC... there are a couple of really good AutoLisp tutorials on the web... if curious, you can look them up... almost a walk through the park...

Yes, I want to start learning to program in lisp but I am currently short on free time. When I start programming, I'll probably come back with more questions! ;)

JBC
.......
"The more I read, the more I acquire, the more certain I am that I know nothing"

(OP)
You're welcome any time Juan!
Old threads tend to get locked after a period of inactivity, so don't hesitate to start a new one to expand this topic.

STF

SparWeb... you've created a really good thread.

Dik

(OP)
You're welcome.
I've been thinking about sharing a number of things to help user configuration of AutoCAD. The LISP file was the obvious starting point.
Given the interest in this thread, I now want to create more new threads about other user configuration details, such as "Workspace", desktop link switches, keyboard shortcuts in the PGP file, etc.

I find that users new and old are presented with the default workspace of AutoCAD and are either overwhelmed by the mess or offended by the clutter. (I'm the latter).
There's a dramatic difference between the user experience of AutoCAD (keyboard+mouse) compared to nearly every other professional software interface (mouse exclusively).
I guess I'm wandering into "user interface" issues... probably worth a thread of its own, too.

STF

(OP)
Some folks on Eng-Tips know this already, but for the rest of you: I started a new job last week.

LT doesn't accept LISP.

BOOHOOO

STF

Try and see if they can use Bricscad... 99.9% AutoCAD compatible, costs less than LT and
has 4 or 5 programming environments as well as Lisp, and does 3D. I've opened 50 meg 3D

Wordwrap doesn't seem to be working... Put in 'hard' breaks.

Dik

(OP)
Thank you dik, for the suggestion. It's greatly appreciated.
Unfortunately, the PC's are all "locked down" and I do not have ADMIN privileges, either!
I can't even delete the "bloatware" icons on my desktop!

STF

Locked down, eh... wanna know how? I do nearly all my work on my laptop.
I can be working on it before the login screen comes up on the office
desktop. I'm not a cad operator, but, use it and often provide details
for normal CAD operators. I also have thousands of standard details that
I use for projects.

You may want to talk to management about changing... if you need to provide
a client with an 'official' autocad drawing, then have one dedicated work
station for this. Look into Bricscad, you could save your company several
thousand dollars. I know how difficult it is... I tried approaching our
company for the same reason.

Dik

(OP)
I've been busy kicking anthills at this new job. Probably more than I can handle. I'd better keep IT on my side, and they seem stretched thin as it is...

STF

...just remember, when challenges befuddle you, there's nothing like a good hanging, to clear the senses.

Dik

(OP)
Mine or theirs?!

STF

yes...

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!