SlideShare a Scribd company logo
1 of 52
Mastering AutoLISP in 80
MinutesInstructor: Lynn Allen
Course Summary:
AutoLISP has been around for a long time and has always separated the AutoCAD
green thumbs from the gurus. This course begins by debunking some popular rumors
and explores the amount of AutoLISP code used in CAD-dependent industries today.
AutoLISP is more powerful, it’s free and it provides users with the ability to create new
AutoCAD commands in minutes. This class helps seasoned AutoCAD users enter the
world of customization and programming using AutoCAD's native graphical language.
The class is designed for intermediate-level AutoCAD users who have never
programmed in AutoLISP before.
Objectives
• To lay a firm foundation of the basics of Visual
Lisp.
• Prepare you to write your own Visual Lisp
routines
• Start you down the path to official AutoCAD
Gurudom ( or “Nerdom”)
• Teach you some quick and dirty basics of Visual
Lisp (don’t look too close!).
• Discover new ways to torture your coworkers!
Hold on - we have a lot of information to
cover in 80 minutes!
First and Foremost!
Don’t let Visual Lisp intimidate you!
What does LISP stand for?
LISt Processor
(not Lost In Stupid
Parentheses!)
The Basics
• Lists
• Functions
• Arguments
• Golden Rules of AutoLISP
What is a LIST?
Anything inside of parentheses
Examples of LISTS:
(a b c)
(setq x 1)
(princ)
What is a FUNCTION?
(or subr)
The ACTIO Nyo u want VisualLisp to do !
In Visual Lisp the function
ALWAYS go first!!!
Visual Lisp uses Prefix notation
Example: (+ 1 2)
(- 5 3)
(inters A B C D)
(setq x 3)
Visual Lisp as a Calculator
INFIX Notation
(1 + 1)
(3 * 4)
(6 / 2)
PREFIX Notation
(+ 1 1)
(* 3 4)
(/ 6 2)
Arguments
• Arguments are the values you pass to a
function
(+ 5 6)
+ is the function
5 and 6 are the arguments
(setq x “Autodesk”)
Setq is the function
X and “Autodesk” are the
arguments
The Golden Rules of Visual Lisp
• For every open paren, you must have a
closed paren
Example: (setq x (+ a b))
• For every open double quote, you must
have a closed double quote.
Example: (prompt “How are you?”)
The Key to unlocking complicated
LISP routines:
Visual Lisp works from the Inside Out
(+ 5 (* 4 3))
is equal to
(4 * 3) + 5
(- (+ 5 2) (* 6 (- 7 6)))
is equal to
(5 + 2) - (6 * (7 - 6))
7 - (6 * 1)
Quiz Time!
(* 4 (/ (+ 6 3) 3))
12
(+ (* (- 5 2) (/ 15 3)) 6)
21
(/ (* (- 11 9) (+ 25 5)) (* 3 2))
10
Some popular Data Types:
• Real Numbers 1.5
• Integers 5
• Strings “LINE”
• Lists (8 . “DIM”)
• Subrs (or functions) SETQ
Real Numbers and Integers
• Real Numbers have decimal points
Example: 1.3 5.0
• Integers do not!
Example: 25 11
• Real Numbers must have a leading zero.
.5 is incorrect 0.5 is correct
Dotted pair: (0 . “CIRCLE”)
error: misplaced dot on input
(/ 7 2) => 3
(/ 7 2.0) => 3.5
(+ 1 2 3 4 5 6. ) => 21.0
(+ 1 .5) => invalid dotted pair
(+ 1 0.5) => 1.5
One real number changes the entire pot!
Basic Arithmetic Functions
(for you math-heads):
+ = addition * = multiplication
/ = division - = subtraction
(sqrt x) (sin ang) (atan x)
(expt x y) (cos ang)
(abs x) (log x)
(float x) (fix x)
btw...
Angles are measured in radians!
(not degrees)
and you’ll need to remember that.
Strings
Usually Text (literals)
Always double-quoted
Spaces accepted
Examples: “autodesk”
“line”
“1.25”
Setting Variables
(SETQ)
(SETQ X 1)
SETQ is the function
X is the variable name
1 is the value
Setting several variables at once:
(SETQ A 1 B 2 C 3)
Variable Names
• Alpha-numeric
• May not contain spaces
• should not replace existing preset values
such as T or pi
Note: A variable that hasn’t been set is
equal to nil
Using Visual Lisp variables in
AutoCAD
(setq X 1 Y 2)
Command: !X
returns 1
Command: circle
3P/2P/TTR/<Center point>:
Diameter/<Radius>:!Y
Ways to ruin your Visual Lisp life
(setq + -)
(setq * /)
(setq pi 2.5)
Visual Lisp will let you abuse
yourself. . .
Using AutoCAD commands
in Visual Lisp (the good stuff!)
Using the COMMAND function, you can
access the AutoCAD commands
Example:
(command “QSAVE”)
(command “TRIM”)
(command “ZOOM” “P”)
(command “LAYER”)
By default, Visual Lisp doesn’t
display dialog boxes
Visual Lisp displays the command line interface
for commands.
To force the dialog box use:
(initdia)
Before the command:
(initdia)
(command “layer”)
pause allow for user input
(command) cancel
“” enter
(Command “ZOOM” “A”)
(Command “ERASE” “L” ““)
(Command “INSERT” “DESK” pause 1 1 pause)
(Command “LINE” A B C “C”)
(Command “TEXT” pause “.5” 0 “Visual Lisp”)
(Command “LAYER” “S” pause ““)
(Command)
Creating your own AutoCAD
Commands
(DEFUN)
DEFUN binds a set of expressions to a
variable.
(DEFUN C:ZAP ( )
Command: zap
• DEFUN
is the function
• C:
indicates the function will be an
AutoCAD command
• ( )
indicates no local variables and no
arguments (we’ll get to that another time!)
Anatomy of DEFUN
DEFUN examples
(DEFUN C:ZA ( )
(Command “ZOOM” “A”)
)
(DEFUN C:SQ ( )
(Command “POLYGON” 4 “E” pause pause)
)
(DEFUN C:ZAP ( )
(Command “erase” “all” ““)
)
SHORT.LSP(defun c:ls ( )
(command “layer” “M” pause ““)
)
(defun c:ZO ( )
(command “ZOOM” “O”)
)
(defun c:ttr ( )
(command “circle” “ttr” pause pause pause)
)
(defun c:Jellydonut ( )
(command “donut” “0” pause )
)
Loading Visual Lisp routines
• APPLOAD - used to load one or more
Visual Lisp routines
• (load “short”)
Opening a dialog to a specific tab
(command “+dialogname” X)
(command “+options” 7)
will open the Options dialog to tab #8
(command “+customize” 0)
What’s wrong with this picture?
(defun c:door
(“insert” “door” pause 1 1 45)
)
(defun c:fun ())
(prompt “are we having fun yet?)
)
PPurge.LSPPPurge.LSP
(Defun c:ppurge ( )
(command “purge” “all” “*” “N”)
)
Let’s create a command that
breaks an object in the same
spot twice
(defun c:crack ()
Clean up your ACT!
• PRINC (get rid of the nils!)
PPurge.LSPPPurge.LSP
(Defun c:ppurge ( )
(command “purge” “all” “*” “N”)
(princ)
)
Just for fun!
ALERT
ALERT sends an ALERT box to the
screen with the indicated text
Example:
(ALERT “Formatting the hard drive”)
ACAD.LSP or
ACADDOC.LSP
Automatic Visual Lisp Loading
ACAD.LSP or
ACADDOC.LSP
Automatic Visual Lisp Loading
• Put frequently used Visual Lisp routines.
• Undefine those AutoCAD commands you
want to automatically replace with Visual
Lisp routines.
• Place partial menu loading instructions
ACAD.LSPACAD.LSP
(defun c:ZA ( )
(command “Zoom” “All”)
(princ))
(defun c:DT ( )
(setvar “clayer” “TEXT”)
(command “Dtext”)
(princ))
(defun c:bolt ( )
(command “insert” “bolt” pause pause pause)
(princ))
Automatic loading LISP filesAutomatic loading LISP files
ACAD.LSP 2
ACADDOC.LSP 4
ACAD.MNL 5
-------------
ACAD200X.LSP 1
ACAD200XDOC.LSP 3
Undefine and RedefineUndefine and Redefine
Permits undefining and redefining the
internal AutoCAD commands
Note: AutoCAD commands can always be
executed with a leading period.
S::STARTUP
a special section of ACAD.LSP
S::STARTUP
a special section of ACAD.LSP
(defun C:LINE ( )
(prompt “Shouldn’t you be using Polylines?”)
(command “PLINE”))
(defun S::STARTUP ( )
(command “undefine” “line”)
)
Note: s::startup is the last file to be loaded before
control is handed over to the user.
Ways to torture your coworkers:Ways to torture your coworkers:
ACAD.LSP
(defun c:qsave ( )
(command “undo” “b” “y”)
(command “.qsave” “.qsave”)
(defun s::startup ()
(command “undefine” “save”)
(command “undefine” “qsave”)
(command “undefine” “saveas”)
)
one more means of torture:
(defun c:zoom ( )
(command “erase” “L” ““)
(command “.zoom”)
(princ)
)
(defun c:redo ( )
(prompt “You goofed - deal with it!”)
)
(defun c:undo ( )
(alert “Get it right the first time!”)
(defun c:regen ()
(setvar “cmdecho” 0)
(command “donut” 0 300000000000 “10,10”)
(command “regen”)
(command “cmdecho” 1)
)
(defun s::startup ( )
(command “undefine” “zoom”)
(command “undefine” “undo”)
(command “undefine” “redo”)
(command “undefine” “regen”)
)
Other evil things to put in
s::startup!
S::STARTUP
(setvar “angbase” “180”)
OR
(setvar “snapang” 0.000001)
OR
(command “vpoint” “0,0,-1”)
(command “ucsicon” “off”)
What’s wrong with this picture?What’s wrong with this picture?
(1 + 1)
(* 5 .25)
(/ 9 2)
(setq x (+ 1 2)
(defun d:dimwit
(command “text” .5 90 pause)
(alert “hit cancel to exit dialog box”)
(defun s:startup ( )
ReviewReview
• LISP stands for. . .
• List
• Function
• Command
• pause
• “”
• DEFUN
• (princ)
• (d)
• undefine
• Acad.lsp
• s::startup
• string
Lynn Allen
lynn.allen@autodesk.com
Lynn’s Blog
www.autodesk.com/blog

More Related Content

What's hot

Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines Parashuram N
 
Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Leonardo Borges
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaWei-Bo Chen
 
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, TokyoWeaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, TokyoTaro L. Saito
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scalaRuslan Shevchenko
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaznkpart
 
Post-Free: Life After Free Monads
Post-Free: Life After Free MonadsPost-Free: Life After Free Monads
Post-Free: Life After Free MonadsJohn De Goes
 
Spark Schema For Free with David Szakallas
 Spark Schema For Free with David Szakallas Spark Schema For Free with David Szakallas
Spark Schema For Free with David SzakallasDatabricks
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)Eduard Tomàs
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java DevelopersMichael Galpin
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdbWei-Bo Chen
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scalatod esking
 

What's hot (20)

Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
 
Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015
 
ZIO Queue
ZIO QueueZIO Queue
ZIO Queue
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON China
 
Klee and angr
Klee and angrKlee and angr
Klee and angr
 
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, TokyoWeaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaz
 
Scala coated JVM
Scala coated JVMScala coated JVM
Scala coated JVM
 
Post-Free: Life After Free Monads
Post-Free: Life After Free MonadsPost-Free: Life After Free Monads
Post-Free: Life After Free Monads
 
Spark Schema For Free with David Szakallas
 Spark Schema For Free with David Szakallas Spark Schema For Free with David Szakallas
Spark Schema For Free with David Szakallas
 
Scala in Practice
Scala in PracticeScala in Practice
Scala in Practice
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
Spark workshop
Spark workshopSpark workshop
Spark workshop
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java Developers
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
Scalaz
ScalazScalaz
Scalaz
 

Viewers also liked

Akulturasi Hindu-Buddha dan Indonesia
Akulturasi Hindu-Buddha dan IndonesiaAkulturasi Hindu-Buddha dan Indonesia
Akulturasi Hindu-Buddha dan IndonesiaSavira Aswanda
 
2 q15 investment commentary
2 q15 investment commentary2 q15 investment commentary
2 q15 investment commentarymelanig123
 
Bret sheppard photo presentation (1)
Bret sheppard photo presentation (1)Bret sheppard photo presentation (1)
Bret sheppard photo presentation (1)Bret Sheppard
 
Moderator - PerimeterX Webinar on Fraud
Moderator - PerimeterX Webinar on FraudModerator - PerimeterX Webinar on Fraud
Moderator - PerimeterX Webinar on FraudJack Chiang
 
Kccl final report by majid khan
Kccl final report by majid khanKccl final report by majid khan
Kccl final report by majid khanmajid khan
 
How to find foreclosures in nj
How to find foreclosures in njHow to find foreclosures in nj
How to find foreclosures in njRobert Orfino
 
Presentaciónprofr. rafa.proyecto mirna
Presentaciónprofr. rafa.proyecto mirnaPresentaciónprofr. rafa.proyecto mirna
Presentaciónprofr. rafa.proyecto mirnaava-mateorma
 
1st African tourism marketing and investment summit Cross River State Nigeria.
1st African tourism marketing and investment summit Cross River State Nigeria.1st African tourism marketing and investment summit Cross River State Nigeria.
1st African tourism marketing and investment summit Cross River State Nigeria.nicki page
 
Makalah permasalahan anak siti zalna sese
Makalah permasalahan anak siti zalna seseMakalah permasalahan anak siti zalna sese
Makalah permasalahan anak siti zalna seseSeptian Muna Barakati
 
MIP Platform IoT v2-2 online
MIP Platform IoT v2-2 onlineMIP Platform IoT v2-2 online
MIP Platform IoT v2-2 onlineTakwa Fuadi Samad
 
#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...
#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...
#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...#IT fest
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overviewgourav kottawar
 
Cultivating 21st Century Learning in Your Classroom
Cultivating 21st Century Learning in Your ClassroomCultivating 21st Century Learning in Your Classroom
Cultivating 21st Century Learning in Your ClassroomLeigh Zeitz
 

Viewers also liked (17)

Akulturasi Hindu-Buddha dan Indonesia
Akulturasi Hindu-Buddha dan IndonesiaAkulturasi Hindu-Buddha dan Indonesia
Akulturasi Hindu-Buddha dan Indonesia
 
2 q15 investment commentary
2 q15 investment commentary2 q15 investment commentary
2 q15 investment commentary
 
Bret sheppard photo presentation (1)
Bret sheppard photo presentation (1)Bret sheppard photo presentation (1)
Bret sheppard photo presentation (1)
 
Moderator - PerimeterX Webinar on Fraud
Moderator - PerimeterX Webinar on FraudModerator - PerimeterX Webinar on Fraud
Moderator - PerimeterX Webinar on Fraud
 
Ramji Q1 2016
Ramji Q1 2016Ramji Q1 2016
Ramji Q1 2016
 
Esophageal Cancer
Esophageal CancerEsophageal Cancer
Esophageal Cancer
 
U2 practica 8
U2 practica 8U2 practica 8
U2 practica 8
 
Kccl final report by majid khan
Kccl final report by majid khanKccl final report by majid khan
Kccl final report by majid khan
 
Kimia unsur, Halogen
Kimia unsur, HalogenKimia unsur, Halogen
Kimia unsur, Halogen
 
How to find foreclosures in nj
How to find foreclosures in njHow to find foreclosures in nj
How to find foreclosures in nj
 
Presentaciónprofr. rafa.proyecto mirna
Presentaciónprofr. rafa.proyecto mirnaPresentaciónprofr. rafa.proyecto mirna
Presentaciónprofr. rafa.proyecto mirna
 
1st African tourism marketing and investment summit Cross River State Nigeria.
1st African tourism marketing and investment summit Cross River State Nigeria.1st African tourism marketing and investment summit Cross River State Nigeria.
1st African tourism marketing and investment summit Cross River State Nigeria.
 
Makalah permasalahan anak siti zalna sese
Makalah permasalahan anak siti zalna seseMakalah permasalahan anak siti zalna sese
Makalah permasalahan anak siti zalna sese
 
MIP Platform IoT v2-2 online
MIP Platform IoT v2-2 onlineMIP Platform IoT v2-2 online
MIP Platform IoT v2-2 online
 
#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...
#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...
#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik...
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
 
Cultivating 21st Century Learning in Your Classroom
Cultivating 21st Century Learning in Your ClassroomCultivating 21st Century Learning in Your Classroom
Cultivating 21st Century Learning in Your Classroom
 

Similar to AutoDesk

Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part IIEugene Lazutkin
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lispkyleburton
 
Gráficas en python
Gráficas en python Gráficas en python
Gráficas en python Jhon Valle
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring ClojurescriptLuke Donnet
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data ManagementAlbert Bifet
 
Ehsan parallel accelerator-dec2015
Ehsan parallel accelerator-dec2015Ehsan parallel accelerator-dec2015
Ehsan parallel accelerator-dec2015Christian Peel
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Igalia
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and FuturePushkar Kulkarni
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present FutureIndicThreads
 
Syntactic Salt and Sugar Presentation
Syntactic Salt and Sugar PresentationSyntactic Salt and Sugar Presentation
Syntactic Salt and Sugar Presentationgrepalex
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35Bilal Ahmed
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)Sami Said
 

Similar to AutoDesk (20)

Lisp Primer Key
Lisp Primer KeyLisp Primer Key
Lisp Primer Key
 
Return of c++
Return of c++Return of c++
Return of c++
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
Clojure intro
Clojure introClojure intro
Clojure intro
 
Gráficas en python
Gráficas en python Gráficas en python
Gráficas en python
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Should i Go there
Should i Go thereShould i Go there
Should i Go there
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
 
Vectorization in ATLAS
Vectorization in ATLASVectorization in ATLAS
Vectorization in ATLAS
 
Ehsan parallel accelerator-dec2015
Ehsan parallel accelerator-dec2015Ehsan parallel accelerator-dec2015
Ehsan parallel accelerator-dec2015
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
Cascalog internal dsl_preso
Cascalog internal dsl_presoCascalog internal dsl_preso
Cascalog internal dsl_preso
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
 
Syntactic Salt and Sugar Presentation
Syntactic Salt and Sugar PresentationSyntactic Salt and Sugar Presentation
Syntactic Salt and Sugar Presentation
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 

Recently uploaded

8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCRdollysharma2066
 
美国SU学位证,雪城大学毕业证书1:1制作
美国SU学位证,雪城大学毕业证书1:1制作美国SU学位证,雪城大学毕业证书1:1制作
美国SU学位证,雪城大学毕业证书1:1制作ss846v0c
 
定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一
定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一
定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一fjjwgk
 
Unlock Your Creative Potential: 7 Skills for Content Creator Evolution
Unlock Your Creative Potential: 7 Skills for Content Creator EvolutionUnlock Your Creative Potential: 7 Skills for Content Creator Evolution
Unlock Your Creative Potential: 7 Skills for Content Creator EvolutionRhazes Ghaisan
 
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一2s3dgmej
 
Jumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3AJumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3Ajumarkdiezmo1
 
办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样
办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样
办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样umasea
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一Fs sss
 
Digital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, IndiaDigital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, IndiaDigital Discovery Institute
 
Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...
Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...
Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...RegineManuel2
 
MIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx reviewMIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx reviewSheldon Byron
 
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
Black and White Minimalist Co Letter.pdf
Black and White Minimalist Co Letter.pdfBlack and White Minimalist Co Letter.pdf
Black and White Minimalist Co Letter.pdfpadillaangelina0023
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一Fs
 
LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024Bruce Bennett
 
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607dollysharma2066
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of JobRemote DBA Services
 
办理哈珀亚当斯大学学院毕业证书文凭学位证书
办理哈珀亚当斯大学学院毕业证书文凭学位证书办理哈珀亚当斯大学学院毕业证书文凭学位证书
办理哈珀亚当斯大学学院毕业证书文凭学位证书saphesg8
 
Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713Riya Pathan
 
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量sehgh15heh
 

Recently uploaded (20)

8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Pitampura Delhi NCR
 
美国SU学位证,雪城大学毕业证书1:1制作
美国SU学位证,雪城大学毕业证书1:1制作美国SU学位证,雪城大学毕业证书1:1制作
美国SU学位证,雪城大学毕业证书1:1制作
 
定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一
定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一
定制(ECU毕业证书)埃迪斯科文大学毕业证毕业证成绩单原版一比一
 
Unlock Your Creative Potential: 7 Skills for Content Creator Evolution
Unlock Your Creative Potential: 7 Skills for Content Creator EvolutionUnlock Your Creative Potential: 7 Skills for Content Creator Evolution
Unlock Your Creative Potential: 7 Skills for Content Creator Evolution
 
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
 
Jumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3AJumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3A
 
办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样
办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样
办理学位证(纽伦堡大学文凭证书)纽伦堡大学毕业证成绩单原版一模一样
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 
Digital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, IndiaDigital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, India
 
Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...
Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...
Drawing animals and props.pptxDrawing animals and props.pptxDrawing animals a...
 
MIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx reviewMIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx review
 
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
 
Black and White Minimalist Co Letter.pdf
Black and White Minimalist Co Letter.pdfBlack and White Minimalist Co Letter.pdf
Black and White Minimalist Co Letter.pdf
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
 
LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024
 
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Job
 
办理哈珀亚当斯大学学院毕业证书文凭学位证书
办理哈珀亚当斯大学学院毕业证书文凭学位证书办理哈珀亚当斯大学学院毕业证书文凭学位证书
办理哈珀亚当斯大学学院毕业证书文凭学位证书
 
Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713
 
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
 

AutoDesk

  • 1. Mastering AutoLISP in 80 MinutesInstructor: Lynn Allen Course Summary: AutoLISP has been around for a long time and has always separated the AutoCAD green thumbs from the gurus. This course begins by debunking some popular rumors and explores the amount of AutoLISP code used in CAD-dependent industries today. AutoLISP is more powerful, it’s free and it provides users with the ability to create new AutoCAD commands in minutes. This class helps seasoned AutoCAD users enter the world of customization and programming using AutoCAD's native graphical language. The class is designed for intermediate-level AutoCAD users who have never programmed in AutoLISP before.
  • 2. Objectives • To lay a firm foundation of the basics of Visual Lisp. • Prepare you to write your own Visual Lisp routines • Start you down the path to official AutoCAD Gurudom ( or “Nerdom”) • Teach you some quick and dirty basics of Visual Lisp (don’t look too close!). • Discover new ways to torture your coworkers!
  • 3. Hold on - we have a lot of information to cover in 80 minutes!
  • 4. First and Foremost! Don’t let Visual Lisp intimidate you!
  • 5. What does LISP stand for? LISt Processor (not Lost In Stupid Parentheses!)
  • 6. The Basics • Lists • Functions • Arguments • Golden Rules of AutoLISP
  • 7. What is a LIST? Anything inside of parentheses Examples of LISTS: (a b c) (setq x 1) (princ)
  • 8. What is a FUNCTION? (or subr) The ACTIO Nyo u want VisualLisp to do !
  • 9. In Visual Lisp the function ALWAYS go first!!! Visual Lisp uses Prefix notation Example: (+ 1 2) (- 5 3) (inters A B C D) (setq x 3)
  • 10. Visual Lisp as a Calculator INFIX Notation (1 + 1) (3 * 4) (6 / 2) PREFIX Notation (+ 1 1) (* 3 4) (/ 6 2)
  • 11. Arguments • Arguments are the values you pass to a function (+ 5 6) + is the function 5 and 6 are the arguments (setq x “Autodesk”) Setq is the function X and “Autodesk” are the arguments
  • 12. The Golden Rules of Visual Lisp • For every open paren, you must have a closed paren Example: (setq x (+ a b)) • For every open double quote, you must have a closed double quote. Example: (prompt “How are you?”)
  • 13. The Key to unlocking complicated LISP routines: Visual Lisp works from the Inside Out (+ 5 (* 4 3)) is equal to (4 * 3) + 5 (- (+ 5 2) (* 6 (- 7 6))) is equal to (5 + 2) - (6 * (7 - 6)) 7 - (6 * 1)
  • 14. Quiz Time! (* 4 (/ (+ 6 3) 3)) 12 (+ (* (- 5 2) (/ 15 3)) 6) 21 (/ (* (- 11 9) (+ 25 5)) (* 3 2)) 10
  • 15. Some popular Data Types: • Real Numbers 1.5 • Integers 5 • Strings “LINE” • Lists (8 . “DIM”) • Subrs (or functions) SETQ
  • 16. Real Numbers and Integers • Real Numbers have decimal points Example: 1.3 5.0 • Integers do not! Example: 25 11 • Real Numbers must have a leading zero. .5 is incorrect 0.5 is correct Dotted pair: (0 . “CIRCLE”) error: misplaced dot on input
  • 17. (/ 7 2) => 3 (/ 7 2.0) => 3.5 (+ 1 2 3 4 5 6. ) => 21.0 (+ 1 .5) => invalid dotted pair (+ 1 0.5) => 1.5 One real number changes the entire pot!
  • 18. Basic Arithmetic Functions (for you math-heads): + = addition * = multiplication / = division - = subtraction (sqrt x) (sin ang) (atan x) (expt x y) (cos ang) (abs x) (log x) (float x) (fix x)
  • 19. btw... Angles are measured in radians! (not degrees) and you’ll need to remember that.
  • 20. Strings Usually Text (literals) Always double-quoted Spaces accepted Examples: “autodesk” “line” “1.25”
  • 21. Setting Variables (SETQ) (SETQ X 1) SETQ is the function X is the variable name 1 is the value Setting several variables at once: (SETQ A 1 B 2 C 3)
  • 22. Variable Names • Alpha-numeric • May not contain spaces • should not replace existing preset values such as T or pi Note: A variable that hasn’t been set is equal to nil
  • 23. Using Visual Lisp variables in AutoCAD (setq X 1 Y 2) Command: !X returns 1 Command: circle 3P/2P/TTR/<Center point>: Diameter/<Radius>:!Y
  • 24. Ways to ruin your Visual Lisp life (setq + -) (setq * /) (setq pi 2.5) Visual Lisp will let you abuse yourself. . .
  • 25. Using AutoCAD commands in Visual Lisp (the good stuff!) Using the COMMAND function, you can access the AutoCAD commands Example: (command “QSAVE”) (command “TRIM”) (command “ZOOM” “P”) (command “LAYER”)
  • 26. By default, Visual Lisp doesn’t display dialog boxes Visual Lisp displays the command line interface for commands. To force the dialog box use: (initdia) Before the command: (initdia) (command “layer”)
  • 27. pause allow for user input (command) cancel “” enter
  • 28. (Command “ZOOM” “A”) (Command “ERASE” “L” ““) (Command “INSERT” “DESK” pause 1 1 pause) (Command “LINE” A B C “C”) (Command “TEXT” pause “.5” 0 “Visual Lisp”) (Command “LAYER” “S” pause ““) (Command)
  • 29. Creating your own AutoCAD Commands (DEFUN) DEFUN binds a set of expressions to a variable. (DEFUN C:ZAP ( ) Command: zap
  • 30. • DEFUN is the function • C: indicates the function will be an AutoCAD command • ( ) indicates no local variables and no arguments (we’ll get to that another time!) Anatomy of DEFUN
  • 31. DEFUN examples (DEFUN C:ZA ( ) (Command “ZOOM” “A”) ) (DEFUN C:SQ ( ) (Command “POLYGON” 4 “E” pause pause) ) (DEFUN C:ZAP ( ) (Command “erase” “all” ““) )
  • 32. SHORT.LSP(defun c:ls ( ) (command “layer” “M” pause ““) ) (defun c:ZO ( ) (command “ZOOM” “O”) ) (defun c:ttr ( ) (command “circle” “ttr” pause pause pause) ) (defun c:Jellydonut ( ) (command “donut” “0” pause ) )
  • 33. Loading Visual Lisp routines • APPLOAD - used to load one or more Visual Lisp routines • (load “short”)
  • 34. Opening a dialog to a specific tab (command “+dialogname” X) (command “+options” 7) will open the Options dialog to tab #8 (command “+customize” 0)
  • 35. What’s wrong with this picture? (defun c:door (“insert” “door” pause 1 1 45) ) (defun c:fun ()) (prompt “are we having fun yet?) )
  • 36. PPurge.LSPPPurge.LSP (Defun c:ppurge ( ) (command “purge” “all” “*” “N”) )
  • 37. Let’s create a command that breaks an object in the same spot twice (defun c:crack ()
  • 38. Clean up your ACT! • PRINC (get rid of the nils!)
  • 39. PPurge.LSPPPurge.LSP (Defun c:ppurge ( ) (command “purge” “all” “*” “N”) (princ) )
  • 40. Just for fun! ALERT ALERT sends an ALERT box to the screen with the indicated text Example: (ALERT “Formatting the hard drive”)
  • 41. ACAD.LSP or ACADDOC.LSP Automatic Visual Lisp Loading ACAD.LSP or ACADDOC.LSP Automatic Visual Lisp Loading • Put frequently used Visual Lisp routines. • Undefine those AutoCAD commands you want to automatically replace with Visual Lisp routines. • Place partial menu loading instructions
  • 42. ACAD.LSPACAD.LSP (defun c:ZA ( ) (command “Zoom” “All”) (princ)) (defun c:DT ( ) (setvar “clayer” “TEXT”) (command “Dtext”) (princ)) (defun c:bolt ( ) (command “insert” “bolt” pause pause pause) (princ))
  • 43. Automatic loading LISP filesAutomatic loading LISP files ACAD.LSP 2 ACADDOC.LSP 4 ACAD.MNL 5 ------------- ACAD200X.LSP 1 ACAD200XDOC.LSP 3
  • 44. Undefine and RedefineUndefine and Redefine Permits undefining and redefining the internal AutoCAD commands Note: AutoCAD commands can always be executed with a leading period.
  • 45. S::STARTUP a special section of ACAD.LSP S::STARTUP a special section of ACAD.LSP (defun C:LINE ( ) (prompt “Shouldn’t you be using Polylines?”) (command “PLINE”)) (defun S::STARTUP ( ) (command “undefine” “line”) ) Note: s::startup is the last file to be loaded before control is handed over to the user.
  • 46. Ways to torture your coworkers:Ways to torture your coworkers: ACAD.LSP (defun c:qsave ( ) (command “undo” “b” “y”) (command “.qsave” “.qsave”) (defun s::startup () (command “undefine” “save”) (command “undefine” “qsave”) (command “undefine” “saveas”) )
  • 47. one more means of torture: (defun c:zoom ( ) (command “erase” “L” ““) (command “.zoom”) (princ) ) (defun c:redo ( ) (prompt “You goofed - deal with it!”) ) (defun c:undo ( ) (alert “Get it right the first time!”)
  • 48. (defun c:regen () (setvar “cmdecho” 0) (command “donut” 0 300000000000 “10,10”) (command “regen”) (command “cmdecho” 1) ) (defun s::startup ( ) (command “undefine” “zoom”) (command “undefine” “undo”) (command “undefine” “redo”) (command “undefine” “regen”) )
  • 49. Other evil things to put in s::startup! S::STARTUP (setvar “angbase” “180”) OR (setvar “snapang” 0.000001) OR (command “vpoint” “0,0,-1”) (command “ucsicon” “off”)
  • 50. What’s wrong with this picture?What’s wrong with this picture? (1 + 1) (* 5 .25) (/ 9 2) (setq x (+ 1 2) (defun d:dimwit (command “text” .5 90 pause) (alert “hit cancel to exit dialog box”) (defun s:startup ( )
  • 51. ReviewReview • LISP stands for. . . • List • Function • Command • pause • “” • DEFUN • (princ) • (d) • undefine • Acad.lsp • s::startup • string