Presentation is loading. Please wait.

Presentation is loading. Please wait.

1© 2006 Autodesk AutoCAD: Secrets Every User Should Know Chapter 9 – AutoLISP by Example: Getting Better.

Similar presentations


Presentation on theme: "1© 2006 Autodesk AutoCAD: Secrets Every User Should Know Chapter 9 – AutoLISP by Example: Getting Better."— Presentation transcript:

1 1© 2006 Autodesk AutoCAD: Secrets Every User Should Know Chapter 9 – AutoLISP by Example: Getting Better

2 2© 2006 Autodesk Debugging

3 3© 2006 Autodesk Debugging Quotation Marks Too Much Magenta? Parenthesis Jumping Step to End/Beginning Ctrl+[ and Ctrl+] Check Program Variables Set break point Add to Watch window !variable name at AutoCAD command line Type variable at console in VLISP

4 4© 2006 Autodesk Debugging Parenthesis Jumping

5 5© 2006 Autodesk Debugging Broken Program - Add Variable to Watch Window

6 6© 2006 Autodesk Debugging Broken Program - Add Break Points

7 7© 2006 Autodesk Final Touches Command Echo Command: SSECT Angle of structural section : ucs Current ucs name: *WORLD* Enter an option [New/Move/orthoGraphic/Prev/Restore/Save/Del/Apply/? /World] : z Specify rotation angle about Z axis : 0.000000000000000 Command: First corner of rectangle: Diagonal corner of rectangle RECTANG Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]: Etc… etc…etc… Command: nil CMDECHO = 0 Command: ssect Angle of structural section : First corner of rectangle: Diagonal corner of rectangle

8 8© 2006 Autodesk Error Handling and Annotation

9 9© 2006 Autodesk Error Handling Two General Strategies Global - Sets an Undo M and rolls back Local - specific to individual program - preferred 1.Start UNDO group with BEgin option. 1.Save variables that are changed in the program using SETQ. 1.Write an error-trapping function that resets those variables. 1.Place the error-trapping function in file immediately before the command function it applies to.

10 10© 2006 Autodesk Error Handling

11 11© 2006 Autodesk Annotation

12 12© 2006 Autodesk Annotation

13 13© 2006 Autodesk Entity Selection and Manipulation

14 14© 2006 Autodesk Entity Selection ASSOC, ENTSEL, ENTGET Very Important Line of Code Assoc 5 Gives You the Entity’s Handle Change the 5 to 0, and You Get the Entity Type Other DXF Group Codes Give You Other Information

15 15© 2006 Autodesk Entity Selection Break Down the Code from the Inside Out (car (entsel) Returns first item in list (entsel)Prompted to select one entity Returns the pick point and name ( (46.904 22.3015 0.0))

16 16© 2006 Autodesk Entity Selection Break Down the Code from the Inside Out (entget (car (entsel))) Returns association lists of entity’s data ((-1. ) (0. "CIRCLE") (330. ) (5. "8D") (100. "AcDbEntity") (67. 0) (410. "Model") (8. "0") (48. 2.2222) (100. "AcDbCircle") (10 51.9761 28.3512 0.0) (40. 7.95186) (210 0.0 0.0 1.0))

17 17© 2006 Autodesk Entity Selection Break Down the Code from the Inside Out (assoc 5 (entget (car (entsel)))) Returns association list 5 (entity’s handle) ((-1. ) (0. "CIRCLE") (330. ) (5. "8D") (100. "AcDbEntity") (67. 0) (410. "Model") (8. "0") (48. 2.2222) (100. "AcDbCircle") (10 51.9761 28.3512 0.0) (40. 7.95186) (210 0.0 0.0 1.0))

18 18© 2006 Autodesk Entity Selection Break Down the Code from the Inside Out (cdr (assoc 5 (entget (car (entsel))))) Returns all but first item in association list 5 ((-1. ) (0. "CIRCLE") (330. ) (5. "8D") (100. "AcDbEntity") (67. 0) (410. "Model") (8. "0") (48. 2.2222) (100. "AcDbCircle") (10 51.9761 28.3512 0.0) (40. 7.95186) (210 0.0 0.0 1.0))

19 19© 2006 Autodesk Entity Selection DXF Group Codes – Help System in VLISP Some Examples: 0Entity type 7Entity’s text style name 8Entity’s layer name 10Entity’s primary point 48Entity’s linetype scale 62Entity’s color Some Codes Not Listed if They Are Defaults 48 is nil if Entity’s LTSCALE is 1

20 20© 2006 Autodesk Entity Selection Sample Program A selective matchprop command for just linetype scale (entget)

21 21© 2006 Autodesk Entity Selection SSGET Can Have Conditions Let’s select: All text between 2 and 6 mm, or Text not on “TEXT” layer, and then… Change Height of all to 3mm Place all on “TEXT” layer.

22 22© 2006 Autodesk ENTMOD, SUBST, ENTUPD Entities Can Be Modified Directly as Well Substitute a New ASSOC List for Existing Modify Entity’s List of Data Update Entity in Drawing

23 23© 2006 Autodesk IF Function Default Setting Meet Condition

24 24© 2006 Autodesk REPEAT Function

25 25© 2006 Autodesk COND Function

26 26© 2006 Autodesk WHILE Function

27 27© 2006 Autodesk Text and String Manipulation

28 28© 2006 Autodesk GETFILED AutoCAD Release Format Get File Dialog Box

29 29© 2006 Autodesk DOS in AutoLISP Use SHELL, External Command Defined in ACAD.pgp Set SHELL Bit Flag to 0 (Not Documented) to Wait to Return to AutoCAD


Download ppt "1© 2006 Autodesk AutoCAD: Secrets Every User Should Know Chapter 9 – AutoLISP by Example: Getting Better."

Similar presentations


Ads by Google