AutoDesk - SlideShare

Loading...

SlideShare Explore Search You

Upload Login Signup

Search

Submit Search

Home Explore Presentation Courses PowerPoint Courses by LinkedIn Learning Search Successfully reported this slideshow. We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

1 of 52

AutoDesk 338 views Share Like Download ...

Objectives • To lay a firm foundation of the basics of Visual Lisp. • Prepare you to write your own Visual Lisp routines •...

SE3D Follow Published on Jul 22, 2015

Mastering CAD ... Published in: Career 0 Comments 3 Likes Statistics Notes

Full Name Comment goes here. 12 hours ago Delete Reply Block Hold on - we have a lot of information to cover in 80 minutes! Are you sure you want to Yes No Your message goes here

Share your thoughts… Post Be the first to comment

Niyanta Datar , Jr. Engineer at Four Forces at Four Forces Structural & Foundation Consultants 1 year ago

Sridhar Ganesh , ESTE DESIGN at Western Railway 1 year ago

First and Foremost! Don’t let Visual Lisp intimidate you! mustafa damerwala , mechanical engineer @ smb engineers (leader in pollution control equipment in india) at smb engineers pvt ltd 1 year ago No Downloads Views Total views 338 On SlideShare 0 From Embeds 0 Number of Embeds 4 Actions Shares 0 Downloads 26 Comments 0 Likes 3 Embeds 0 No embeds What does LISP stand for? LISt Processor (not Lost In Stupid Parentheses!) No notes for slide

AutoDesk 1. 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. 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. 3. Hold on - we have a lot of information to cover in 80 minutes! 4. 4. First and Foremost! Don’t let Visual Lisp intimidate you! 5. 5. What does LISP stand for? LISt Processor (not Lost In Stupid Parentheses!) 6. 6. The Basics • Lists • Functions • Arguments • Golden Rules of AutoLISP 7. 7. What is a LIST? Anything inside of parentheses Examples of LISTS: (a b c) (setq x 1) (princ) 8. 8. What is a FUNCTION? (or subr) The ACTIO Nyo u want VisualLisp to do ! 9. 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. 10. Visual Lisp as a Calculator INFIX Notation (1 + 1) (3 * 4) (6 / 2) PREFIX Notation (+ 1 1) (* 3 4) (/ 6 2) 11. 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. 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. 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. 14. Quiz Time! (* 4 (/ (+ 6 3) 3)) 12 (+ (* (- 5 2) (/ 15 3)) 6) 21 (/ (* (- 11 9) (+ 25 5)) (* 3 2)) 10 15. 15. Some popular Data Types: • Real Numbers 1.5 • Integers 5 • Strings “LINE” • Lists (8 . “DIM”) • Subrs (or functions) SETQ 16. 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 The Basics • Lists • Functions • Arguments • Golden Rules of AutoLISP 17. 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. 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. 19. btw... Angles are measured in radians! (not degrees) and you’ll need to remember that. 20. 20. Strings Usually Text (literals) Always double-quoted Spaces accepted Examples: “autodesk” “line” “1.25” 21. 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. 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. 23. Using Visual Lisp variables in AutoCAD (setq X 1 Y 2) Command: !X returns 1 Command: circle 3P/2P/TTR/
: Diameter/:!Y 24. 24. Ways to ruin your Visual Lisp life (setq + -) (setq * /) (setq pi 2.5) Visual Lisp will let you abuse yourself. . . 25. 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. 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. 27. pause allow for user input (command) cancel “” enter 28. 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. 29. Creating your own AutoCAD Commands (DEFUN) DEFUN binds a set of expressions to a variable. (DEFUN C:ZAP ( ) Command: zap 30. 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. 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. 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. 33. Loading Visual Lisp routines • APPLOAD - used to load one or more Visual Lisp routines • (load “short”) What is a LIST? Anything inside of parentheses Examples of LISTS: (a b c) (setq x 1) (princ) 34. 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. 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. 36. PPurge.LSPPPurge.LSP (Defun c:ppurge ( ) (command “purge” “all” “*” “N”) ) 37. 37. Let’s create a command that breaks an object in the same spot twice (defun c:crack () 38. 38. Clean up your ACT! • PRINC (get rid of the nils!) 39. 39. PPurge.LSPPPurge.LSP (Defun c:ppurge ( ) (command “purge” “all” “*” “N”) (princ) ) 40. 40. Just for fun! ALERT ALERT sends an ALERT box to the screen with the indicated text Example: (ALERT “Formatting the hard drive”) 41. 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. 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. 43. Automatic loading LISP filesAutomatic loading LISP files ACAD.LSP 2 ACADDOC.LSP 4 ACAD.MNL 5 ------------- ACAD200X.LSP 1 ACAD200XDOC.LSP 3 44. 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. 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. 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. 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. 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. 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. 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 What is a FUNCTION? (or subr) The ACTIO Nyo u want VisualLisp to do ! dialog box”) (defun s:startup ( ) 51. 51. ReviewReview • LISP stands for. . . • List • Function • Command • pause • “” • DEFUN • (princ) • (d) • undefine • Acad.lsp • s::startup • string 52. 52. Lynn Allen [email protected] Lynn’s Blog www.autodesk.com/blog

Recommended

In Visual Lisp the function ALWAYS go first!!! Visual Lisp uses Prefix notation Example: (+ 1 2) (- 5 3) (inters A B C D) ...

Visual Lisp as a Calculator INFIX Notation (1 + 1) (3 * 4) (6 / 2) PREFIX Notation (+ 1 1) (* 3 4) (/ 6 2)

Teacher Tech Tips Weekly Online Course - LinkedIn Learning

Arguments • Arguments are the values you pass to a function (+ 5 6) + is the function 5 and 6 are the arguments (setq x “A...

Teaching Techniques: Blended Learning Online Course - LinkedIn Learning

The Golden Rules of Visual Lisp • For every open paren, you must have a closed paren Example: (setq x (+ a b)) • For every...

The Key to unlocking complicated LISP routines: Visual Lisp works from the Inside Out (+ 5 (* 4 3)) is equal to (4 * 3) + ...

Teacher Tips Online Course - LinkedIn Learning

2 q15 investment commentary melanig123

Akulturasi Hindu-Buddha dan Indonesia Savira Aswanda

Aspire - The Dream Home In Rajarhat bhkrealtors

Quiz Time! (* 4 (/ (+ 6 3) 3)) 12 (+ (* (- 5 2) (/ 15 3)) 6) 21 (/ (* (- 11 9) (+ 25 5)) (* 3 2)) 10 1st African tourism marketing and investment summit Cross River State Nigeria. nicki page

Makalah permasalahan anak siti zalna sese Septian Muna Barakati

MIP Platform IoT v2-2 online Takwa Fuadi Samad

#IT fest 2013 - Co to jest RWD? I kiedy warto myśleć o nim w kontekście aplik... #IT fest Some popular Data Types: • Real Numbers 1.5 • Integers 5 • Strings “LINE” • Lists (8 . “DIM”) • Subrs (or functions) SETQ English Español Português Français Deutsch About Dev & API Blog Terms Privacy Copyright Support

LinkedIn Corporation © 2018 × Share Clipboard Real Numbers and Integers • Real Numbers have decimal points Example: 1.3 5.0 • Integers do not! Example: 25 11 • Real Num... × Email

Enter email addresses Add a message From



Send Email sent successfully.. Facebook Twitter LinkedIn Link Public clipboards featuring this slide

(/ 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 c... ×

Basic Arithmetic Functions (for you math-heads): + = addition * = multiplication / = division - = subtraction (sqrt x) (si...

No public clipboards found for this slide Select another clipboard × 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”

Looks like you’ve clipped this slide to already. Search for a clipboard Create a clipboard

You just clipped your first slide! Clipping is a handy way to collect important slides you want to go back to later. Now customize the name of a clipboard to store your clips. Setting Variables (SETQ) (SETQ X 1) SETQ is the function X is the variable name 1 is the value Setting several variables a... Name* Best of Slides



Description Add a brief description so others know what your Clipboard is about. Visibility Others can see my Clipboard Cancel Save Save this presentationTap To Close

Variable Names • Alpha-numeric • May not contain spaces • should not replace existing preset values such as T or pi Note: ...

Using Visual Lisp variables in AutoCAD (setq X 1 Y 2) Command: !X returns 1 Command: circle 3P/2P/TTR/
: Diam...

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

By default, Visual Lisp doesn’t display dialog boxes Visual Lisp displays the command line interface for commands. To forc...

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”) (Comman...

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

DEFUN examples (DEFUN C:ZA ( ) (Command “ZOOM” “A”) ) (DEFUN C:SQ ( ) (Command “POLYGON” 4 “E” pause pause) ) (DEFUN C:ZAP...

SHORT.LSP(defun c:ls ( ) (command “layer” “M” pause ““) ) (defun c:ZO ( ) (command “ZOOM” “O”) ) (defun c:ttr ( ) (command...

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

What’s wrong with this picture? (defun c:door (“insert” “door” pause 1 1 45) ) (defun c:fun ()) (prompt “are we having fun...

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

ACAD.LSP or ACADDOC.LSP Automatic Visual Lisp Loading ACAD.LSP or ACADDOC.LSP Automatic Visual Lisp Loading • Put frequent...

ACAD.LSPACAD.LSP (defun c:ZA ( ) (command “Zoom” “All”) (princ)) (defun c:DT ( ) (setvar “clayer” “TEXT”) (command “Dtext”...

Automatic loading LISP filesAutomatic loading LISP files ACAD.LSP 2 ACADDOC.LSP 4 ACAD.MNL 5 ------------- ACAD200X.LSP 1 ...

Undefine and RedefineUndefine and Redefine Permits undefining and redefining the internal AutoCAD commands Note: AutoCAD c...

S::STARTUP a special section of ACAD.LSP S::STARTUP a special section of ACAD.LSP (defun C:LINE ( ) (prompt “Shouldn’t you...

Ways to torture your coworkers:Ways to torture your coworkers: ACAD.LSP (defun c:qsave ( ) (command “undo” “b” “y”) (comma...

one more means of torture: (defun c:zoom ( ) (command “erase” “L” ““) (command “.zoom”) (princ) ) (defun c:redo ( ) (promp...

(defun c:regen () (setvar “cmdecho” 0) (command “donut” 0 300000000000 “10,10”) (command “regen”) (command “cmdecho” 1) ) ...

Other evil things to put in s::startup! S::STARTUP (setvar “angbase” “180”) OR (setvar “snapang” 0.000001) OR (command “vp...

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

ReviewReview • LISP stands for. . . • List • Function • Command • pause • “” • DEFUN • (princ) • (d) • undefine • Acad.lsp...

Lynn Allen [email protected] Lynn’s Blog www.autodesk.com/blog

Upcoming SlideShare

Loading in …5

×

Loading...

AutoDesk - SlideShare

SlideShare Explore Search You Upload Login Signup Search Submit Search Home Explore Presentation Courses PowerPoint Courses by LinkedIn Learning ...

437KB Sizes 5 Downloads 13 Views

Recommend Documents

standards and tolerances - Autodesk Community - Autodesk Forum
Jun 4, 2002 - standard and is ususally a 'DIN' type of standard. ex. DIN ISO 2768-mK. Where would one get a standards ma

KKS pipelines - Autodesk Community - Autodesk Forum
Feb 8, 2010 - I am configuring AutoCAD PID with KKS codes and I have reached a problem which I cannot handle. For the eq

Company - Autodesk
Autodesk makes software for people who make things.

Tutorials - Autodesk
Points can be imported from a text file or a Microsoft Access database. Data created in Autodesk Land Desktop can be mig

Inka 3D plugin - Autodesk Community - Autodesk Forum
Feb 22, 2013 - Hi, I'm trying to install the Inka3D plugin to Maya so that I can export for WebGL. I have downloaded the

Benutzerhandbuch - Autodesk
RasterDWG, RealDWG, Real-time Roto, Recognize, Render Queue, Retimer,Reveal, Revit, Showcase, ShowMotion, SketchBook, Sm

Autodesk Moldflow Plastics Labs | Moldflow Adviser | Autodesk
Overview: Autodesk Moldflow Plastics Labs Rely on Autodesk® Moldflow® Plastics Labs for state-of-the-art plastic mater

Autodesk Graphic
Autodesk® Graphic. Graphic is a powerful full-featured design and illustration application. Create everything from deta

Benutzerhandbuch - Autodesk
RasterDWG, RealDWG, Real-time Roto, Recognize, Render Queue, Retimer,Reveal, Revit, Showcase, ShowMotion, SketchBook, Sm

Community | Autodesk Fusion 360
DEC 8, オンライン, Japan, テクニカル セミナー:プロジェクト関係者とのデータ共有と管理ã