© 2006 Autodesk AutoCAD: Secrets Every User Should Know Chapter 8 - AutoLISP by Example: Getting Started.

Slides:



Advertisements
Similar presentations
Join us on Twitter: #AU2013 LISPing on Purpose – Parts 1 & 2 Craig P. Black Instructor of CAD Management, CAD Drafting, and Mechanical Design courses at.
Advertisements

Program Design. Objectives Students should understand the basic steps in the programming process. Students should understand the need for good design.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Fundamentals of Python: From First Programs Through Data Structures Chapter 2 Software Development, Data Types, and Expressions.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Game Programming © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line L.
Chapter Introduction to Computers and Programming 1.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
1 An Introduction to SQL. 2 Objectives  Understand the concepts and terminology associated with relational databases  Create and run SQL commands 
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
Writing Web Pages By Shyam Gurram. Agenda Writing Web Pages Delimiting PHP Program Units. Displaying Output to Web Pages Putting Comments in PHP Programs.
Fundamentals of Python: First Programs
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
© 2011 Autodesk CP5239 Demand-Loading AutoCAD®.NET Plug-ins James E. Johnson Synergis Software Sr. CAD Developer.
1 AutoCAD: Secrets Every User Should Know Chapter 7 - AutoCAD Scripts.
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
Input, Output, and Processing
Computer Science 101 Introduction to Programming.
Chapter 19: Visual Lisp. After completing this Chapter, you will be able to do the following: What is AutoLISP Launching Visual LISP Terminology and Fundamental.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
4 Chapter Four Introduction to HTML. 4 Chapter Objectives Learn basic HTML commands Discover how to display graphic image objects in Web pages Create.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Function Design in LISP. Program Files n LISP programs are plain text –DOS extensions vary; use.lsp for this course n (load “filename.lsp”) n Can use.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 11: Block References and Attributes. After completing this Chapter, you will be able to use the following features: Create and insert block references.
Allegro CL Certification Program Lisp Programming Series Level I Session Basic Lisp Development in the IDE.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
Creating a Java Application and Applet
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
1© 2006 Autodesk AutoCAD: Secrets Every User Should Know Chapter 9 – AutoLISP by Example: Getting Better.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 1: Introduction to Computers and Programming.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
3 A Guide to MySQL.
Fundamentals of Programming I Overview of Programming
C++ First Steps.
Topics Designing a Program Input, Processing, and Output
Chapter 7: Introduction to CLIPS
Microsoft Access Illustrated
Advanced Programming Lecture 02: Introduction to C# Apps
Lisp Tutorial Click on Xlisp icon – you enter the interpreter
Liquid Common Lisp On Suns.
Topics Designing a Program Input, Processing, and Output
Matlab.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Terminal-Based Programs
L L Line CSE 420 Computer Games Lecture #3 Introduction to Python.
Presentation transcript:

© 2006 Autodesk AutoCAD: Secrets Every User Should Know Chapter 8 - AutoLISP by Example: Getting Started

2© 2006 Autodesk Key Topics -Entity Selection and Manipulation -Constructing New Points -String Conversion and Manipulation -Debugging and Troubleshooting Techniques -Annotating and Error-Trapping

3© 2006 Autodesk AutoLISP  Based on LISP from 1950s  Good User Language  Can use AutoCAD commands  Can use AutoCAD variables  VLISP Added AutoCAD 200  Uses AutoCAD Commands VBA and VB.NET C++ Programming Tools

4© 2006 Autodesk Writing  Text Editor  Visual LISP Editor  NO Word Processors Saving  ASCII Text File .LSP extension  ACADDOC.lspLoads in Each Drawing  ACAD.lsp Loads Only When AutoCAD Fires Up Saving AutoLISP Programs

5© 2006 Autodesk Three ways to load AutoLISP  Type it at the command line  or copy/paste to the command line  Load a text file that contains AutoLISP code  (load “program.lsp”)  APPLOAD Startup Suite  Use the load function of the Visual LISP editor Loading Programs

6© 2006 Autodesk Start Visual LISP Editor  VLISP or VLIDE  Tools  AutoLISP  Visual LISP Editor Four Windows  Text editor: type your program (more than one can be open)  Visual LISP console: type variable names or pieces of code  Trace window: use while debugging  Build Output window: warnings and error messages Visual LISP Editor

7© 2006 Autodesk Visual LISP - Color Coding ColorUsed for Blue AutoLISP functions like /, DEFUN, and SETQ MagentaStrings, which are always between quotation marks BlackUser-created items, such as program variables and function names GreenInteger values TealReal numbers, which must have a decimal point Maroon on grayComments, which are preceded by a semicolon

8© 2006 Autodesk VLISP Tools

9© 2006 Autodesk AutoLISP by Example Or format like this:

10© 2006 Autodesk Program Structure Programs Contain AutoLISP Functions  DEFUN, SETVAR, +, and - Function Name Is Preceded by an Opening Parenthesis  (defun, or (command, or (+ Balance Parentheses Separate Atoms with Spaces or Quotation Marks Functions Are Followed by Arguments, if They’re Necessary

11© 2006 Autodesk Breaking Down the Code (defun c:00()Defun is an AutoLISP expression C: means “command” not drive (setvar “osmode” 4143)Setvar is an AutoLISP expression “osmode” is a system variable 4143 is a bit sum setting )Closes opening parenthesis in line 1

12© 2006 Autodesk Bit Sum 1, 2, 4, 8, 16, 32, 64, 128, etc. Why 4143? End, Mid, Cen, Nod, Int, and Ext as running osnaps Type OSMODE at the command line Returns = 4143.

13© 2006 Autodesk Building on the Basics

14© 2006 Autodesk System Variables Over 550 in AutoCAD 2007 Examples: APERTURE; AUPREC; LUPREC Some saved in drawing, others in Registry (getvar “aperture”) (setvar “aperture” 3) Environment Variables – Operating System Examples: “MaxHatch” " HideSystemPrinters" Saved in Registry (getenv “MaxHatch”) (setenv “MaxHatch” “ ”) Background- Variables

15© 2006 Autodesk Program Variables Defined by the programmer using SETQ Global(defun C:MID () Retain their value when program terminates Useful for debugging Often Changed to Local Can be used to create a persistent default value Local(defun C:MID (/ os ap m) Return to nil when program terminates !variable at command line to get value Background - Variables

16© 2006 Autodesk SETQ

17© 2006 Autodesk Deciphering the Code

18© 2006 Autodesk Creating New Coordinates Structural Lumber Symbol Get Point1 and Point 2 from User Create Point3 from X of Point 1 and Y of Point2 Create Point4 from X of Point 2 and Y of Point1

19© 2006 Autodesk Creating New Coordinate Points - LIST

20© 2006 Autodesk Creating New Points - POLAR Dimension Between Walls

21© 2006 Autodesk Creating New Points - POLAR Polar pt Angle Distance

22© 2006 Autodesk Calculations

23© 2006 Autodesk Calculations - More

24© 2006 Autodesk Calculations in Programs

25© 2006 Autodesk Angles Radians vs. Degrees AutoLISP uses Radians Radian: included angle of arc with length of 1 DegreesRadians 00 90Pi/2 180Pi 2703pi/2 3602pi

26© 2006 Autodesk Angles Radian Problems

27© 2006 Autodesk Angles Radians vs. Degrees Conversion Functions

28© 2006 Autodesk Transparent Commands Two Methods ‘I2M will work for many command functions Call non-command functions as Lisp

29© 2006 Autodesk Combining Programs SSECT and RC

30© 2006 Autodesk Ten Basic Rules 1.Save as ASCII. 2.Use Equal Number of Opening and Closing Parens. 3.DEFUN Means Define Function; C:ZX Is a Command. 4.Balance Quotation Marks. 5.Backslash Is a Control Character: \\ or / for Folders. 6.Leave Space After Forward Slash for Local Variables. 7.\n Controls New Line in Prompt and Is Lowercase. 8.Use Semicolons for Comments. 9.Get Values at Beginning; Use SETQ to Save Them. 10. Don't Get Discouraged!

31© 2006 Autodesk Automatic Loading APPLOAD Startup Suite Any LSP program placed by user ACAD.lsp Loads when AutoCAD starts IF in the path Loads in subsequent drawings IF ACADLSPASDOC=1 ACADDOC.lsp Loads with each drawing IF in the path (There are some others, but you probably don’t want to mess them up)

32© 2006 Autodesk Automatic Loading Startup Functions