Download - AutoLISP for Everyone
-
8/11/2019 AutoLISP for Everyone
1/36
AutoLISP for Everyone!Robert Green
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
2/36
AutoCAD user since 1985
Self confessed computer geek
rom an a so
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
3/36
Lets learn some
(This stuff is fun)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
4/36
Some fundamentals
LISP LISt Processor
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
5/36
It was open source (cheap)
entitles are lists
It made sense at the time (cheap)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
6/36
A HUGE base of LISP code exists
LISP does many things very easily as
LISP is weak on dialog controls
View it as an 80/20 language
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
7/36
Key files and why they matter
LSP
What to mess with
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
8/36
ACAD.LSP
.
ACADDOC.LSP
.
Help
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
9/36
They load in a certain order (listed on previousslide)
Some have code in them and some dont
(ACADDOC.LSP and ACAD.LSP dont as anexample)
They reside in the SUPPORT folder
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
10/36
You create your own ACADDOC.LSP so youcant really mess it up
It loads with every new drawing
away
If you mess up too bad, just delete!
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
11/36
Syntax Basics
Lists and Arguments
Variables
Accessing the
Special characters
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
12/36
+
o Here the + is a FUNCTION and the two numbersare ARGUMENTS
(command line 0,0 1,1 )
o Here COMMAND is the function, all others areARGUMENTS
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
13/36
Some RulesFor every ( there is an equal and opposite ) Newton
Like this: (setq A 3.0)
Not like this: (setq A 3.0)) or (setq A 3.0
Same oes for uote marks!
Like this: (setq name Robert Green)
Not like this: (setq name Robert Green)se q name o er reen
When formatting numbers always avoid invalid dotted
pa rsLike this: (setq A 0.5)
Not like this: (setq A .5)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
14/36
Function Lists Embedded ListsStandard AutoLISP Result
8 + 2.3 (+ 8 2.3) 10.3
. . . . .
5 4 (/ 5 4) 1
(8 + 4) * 3 (* (+ 8 4) 3) 36
(3.0 * 5.0) 4.0 (/ (* 3.0 5.0) 4.0) 3.75
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
15/36
How would you work normally?
o Type in LINE to start the line command
o
o Click POINT for second point location
PAUSE waits for the user
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
e s equa o ng e ey
-
8/11/2019 AutoLISP for Everyone
16/36
Whats Going On Here?
(command viewres y 5000)
-
(command -linetype set BYLAYER )
.
(command viewres y pause)
Thats not so bad intuitive actually
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
17/36
Variables and Data Types
Real
String
ser npu
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
18/36
Variables and data types
SETQ (SET eQual)
.
(setq VALUE 1) integer number
(setq VALUE 1.0) - ?
(setq VIEWRES_VALUE 5000) - ?
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
19/36
Variables and Commands
(setq VIEWRES_VALUE 5000)
_
o What would happen in this case?
_
o (command viewres y viewres_value)
Variable TYPES and how they interact with
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
20/36
User functions
Speed for the user
A win-win scenario
e s pu every ng
weve learned into action
to build some functions.
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
21/36
User Function Examples
(command .zoom a)
)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
22/36
User Function Examples
(defun C:VR ()
command viewres 5000
)
(defun C:BL ()
-
(command -linetype set BYLAYER )
)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
23/36
Fillet Zero Function
Fillet Zero
(setvar filletrad 0.0)
.
(princ)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
24/36
Improved Fillet Zero
(defun c:fz ()
_
(setvar filletrad 0.0)
.
(setvar filletrad old_filletrad)
pr nc
)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
25/36
Auto Purge Function
Auto Purge
(command -purge a * n .qsave)
)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
26/36
More Bits and Bytes
Undefine
Dot form
Alerts
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
27/36
Undefining
(command .undefine LINE)
Dont want them messing with a command? Justundefine it
Now ou can SUBTRACT from the
AutoCAD Command set in yourACADDOC.LSP file.
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
28/36
The DOT form
Invoke commands like this: .LINE
This allows you to invoke a command whether it hasbeen undefined or not!
This is our little secret right ...
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
29/36
Redefining
(command .redefine LINE)
Want to be sure that a command is active?
Now ou can UNSUBTRACT from the
AutoCAD Command set with ease.
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
30/36
Undefining revisted
What if your users find out about REDEFINE and start
REDEFINING your UNDEFINES?
Just undefine the redefine like this:
command .undefine REDEFINE
Thatll show em
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
31/36
Redefining
You can undefine a command and redefine it like this:
(defun C:TORUS ()
(princ)
Now you do whatever you want!
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
32/36
-
8/11/2019 AutoLISP for Everyone
33/36
-
8/11/2019 AutoLISP for Everyone
34/36
Command echo (CMDECHO)
Run in STEALTH mode like this:
defun C:BL
(setvar cmdecho 0)command -color BYLAYER
(command -linetype set BYLAYER )
setvar cmdecho 1
(princ)
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
35/36
Wrapping up: Resources
CADDEPOT.com
.
Cadalyst Magazine
e ar en a
Developers Help
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.
-
8/11/2019 AutoLISP for Everyone
36/36
Thank ou for attendin !Any questions?
Email me: [email protected]
Be sure to check out the video segments Ill post at my
-
FROM THE TRAILHEAD TO YOUR CAREER SUMMIT.