### Inform User of Setup Completion Source: https://www.afralisp.net/autolisp/tutorials/drawing-setup-part-3.php Displays a blank line followed by a confirmation message to the user indicating that the setup routine is complete. ```autolisp (prompt "\n ") ;Blank Line (prompt "\nO.K Setup Routine Complete") ;Inform User ``` -------------------------------- ### Entity Data List Output Example Source: https://www.afralisp.net/autolisp/tutorials/into-the-database.php Example of the association list structure returned by entget. ```AutoLISP ((-1 . ) (0 . "LINE") (5 . "270") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 400.378 621.82 0.0) (11 740.737 439.601 0.0) (210 0.0 0.0 1.0)) ``` -------------------------------- ### Define and Setup Drawing Environment in AutoLISP Source: https://www.afralisp.net/autolisp/tutorials/drawing-setup-part-3.php This function defines a new command 'SETUP' that configures drawing environment settings like blip mode, command echo, and osmode. It also loads and interacts with a custom dialog box ('setup.dcl') to allow users to select drawing type and size, then proceeds to call specific setup functions based on user input. ```autolisp (defun C:SETUP () ;define function (setvar "BLIPMODE" 0) ;switch off variables (setvar "CMDECHO" 0) (setvar "OSMODE" 0) (setq typ "e") ;set default (setq dcl_id (load_dialog "setup.dcl")) ;load dialogue (if (not ;test if loaded (new_dialog "setup" dcl_id) ;new dialogue ) ;end not (exit) ;if not loaded, exit ) ;end if (set_tile "rb1" "1") ;switch on radio button (action_tile "rb1" ;if button selected "(setq typ \"e\") ;store sheet type (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb2" ;if button selected "(setq typ \"a\") ;store sheet type (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb3" ;if button selected "(setq typ \"c\") ;store sheet type (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb4" ;if button selected "(setq typ \"el\") ;store sheet type (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb5" ;if button selected "(setq typ \"b\") ;store sheet type (mode_tile \"eb1\" 2)") ;set focus to edit box (set_tile "rb6" "1") ;make default (setq SIZ "A0") ;Default sheet size (set_tile "eb1" "1") ;initial edit box value (mode_tile "eb1" 2) ;set focus to edit box (action_tile "rb6" ;if button selected "(setq siz \"A0\") ;store sheet size (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb7" ;if button selected "(setq siz \"A1\") ;store sheet size (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb8" ;if button selected "(setq siz \"A2\") ;store sheet size (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb9" ;if button selected "(setq siz \"A3\") ;store sheet size (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "rb10" ;if button selected "(setq siz \"A4\") ;store sheet size (mode_tile \"eb1\" 2)") ;set focus to edit box (action_tile "cancel" ;if Cancel selected "(done_dialog)(setq userclick nil)") ;close dialogue, clear flag (action_tile "accept" ;if OK selected (strcat ;string 'em together "(progn (setq #dwgsc ;store value (atof (get_tile \"eb1\")))" ;get edit box value "(done_dialog) (setq userclick T))" ;close dialogue, set flag ) ;end progn ) ;end action_tile (start_dialog) ;start dialogue (unload_dialog dcl_id) ;unload dialogue (if userclick ;if flag is true (progn ;do the following (if (eq siz "A0") ;If size is A0 (progn ;Do the following (setq x 1189.0 ;Set x limits y 841.0 ;Set y limits ) ;End setq ) ;End progn ) ;End If (if (eq siz "A1") ;If size is A1 (progn ;Do the following (setq x 841.0 ;Set x limits y 594.0 ;Set y limits ) ;End setq ) ;End progn ) ;End If (if (eq siz "A2") ;If size is A2 (progn ;Do the following (setq x 594.0 ;Set x limits y 420.0 ;Set y limits ) ;End setq ) ;End progn ) ;End If (if (eq siz "A3") ;If size is A3 (progn ;Do the following (setq x 420.0 ;Set x limits y 297.0 ;Set y limits ) ;End setq ) ;End progn ) ;End If (if (eq siz "A4") ;If size is A4 (progn ;Do the following (setq x 297.0 ;Set x limits y 210.0 ;Set y limits ) ;End setq ) ;End progn ) ;End If (setq SIZE (strcat TYP SIZ)) ;Construct name of Template (if (eq typ "e") (eng)) ;Run Engineering Setup (if (eq typ "a") (arch)) ;Run Architectural Setup (if (eq typ "c") (civil)) ;Run Civil Setup (if (eq typ "el") (elec)) ;Run Electrical Setup (if (eq typ "b") (blank)) ;Run Blank Setup ) ;End progn ) ;End If (princ) ;finish clean ) ;end function ;;;---------------------------------------------------------------------------- (defun blank () ;Define function (setvar "DIMSCALE" #DWGSC) ;Set Dimscale (setvar "USERR1" #DWGSC) ;Store Scale for future (setvar "LTSCALE" ( #DWGSC 10)) ;Set Ltscale (setvar "REGENMODE" 1) ;Regen ON (setvar "TILEMODE" 1) ;Tilemode ON (setq n ( 3.5 #DWGSC)) ;Store Text Height ``` -------------------------------- ### Select entities by window with user prompts Source: https://www.afralisp.net/autolisp/tutorials/selection-sets.php This example demonstrates how to use other AutoLISP functions to get user input for selection criteria, as prompts cannot be directly used within ssget. ```autolisp (setq sel1 (ssget "w" "\nSelect Objects by Window: ")) ``` ```autolisp (prompt "\nSelect Objects by Window") (setq p1 (getpoint "\nFirst Corner: ")) (setq p2 (getpoint p1 "\nSecond Corner: ")) (setq sel1 (ssget "w" p1 p2)) ``` -------------------------------- ### Example usage of findfile Source: https://www.afralisp.net/autolisp/tutorials/locating-files.php An example of searching for a specific file. ```AutoLISP (findfile "ACADR14.LSP) ``` ```AutoLISP "C:\\ACADR14\\SUPPORT\\ACADR14.LSP" ``` -------------------------------- ### Entity Name Output Example Source: https://www.afralisp.net/autolisp/tutorials/into-the-database.php Example of the return value when querying an entity name. ```AutoLISP ``` -------------------------------- ### Setup Drawing Limits and View Source: https://www.afralisp.net/autolisp/tutorials/drawing-setup-part-3.php Calculates drawing limits based on a scale factor and sets them using the LIMITS command. It then zooms to these limits. This is a common setup step before other drawing operations. ```autolisp (setq L (list ( X #DWGSC) ( Y #DWGSC))) ( (command "LIMITS" "0,0" L "ZOOM" "W" "0,0" L ``` -------------------------------- ### Conditional Setup Execution Source: https://www.afralisp.net/autolisp/tutorials/drawing-setup-part-2.php Conditional logic to trigger specific setup sub-routines based on the provided type variable. ```AutoLISP (if (eq typ "a") (arch)) ;Run Architectural Setup (if (eq typ "c") (civil)) ;Run Civil Setup (if (eq typ "el") (elec)) ;Run Electrical Setup (if (eq typ "b") (blank)) ;Run Blank Setup ) ;End progn ) ;End If (princ) ;finish clean ) ``` -------------------------------- ### AutoLISP SETQ and SET Example Source: https://www.afralisp.net/autolisp/tutorials/set-and-setq.php This example demonstrates dynamic symbol creation and assignment using SETQ and SET. It prompts the user for multiple points, stores them in dynamically named symbols, sorts them by Y-coordinate, and then draws a line connecting them. Use this when the number of variables is not known in advance. ```autolisp (defun c:test ( / j lpt symb) (setq j 1) (while (set (read (strcat "point_" (itoa j))) (getpoint "\nPoint : ") ) (setq j (1+ j)) ) ;; Last point is nil. (setq j (1- j)) ;; Sort the points. See function "sortpoints" below. (sortpoints j) ;; Initialize the list of points to be passed to (command "_line") (setq lpt (list "")) ;; Construct the list and set each of our ;; "on the fly" symbols to nil (while (> j 0) (setq symb (read (strcat "point_" (itoa j))) lpt (cons (eval symb) lpt) ) (set symb nil) (setq j (1- j)) ) ;; draw the line (command "_line") (mapcar 'command lpt) (princ) ) ;; This function sorts the points by their Y coordinate (defun sortpoints (j / i cur_y prev_y cur_symb prev_symb point) (setq i 2) (while (<= i j) (setq cur_symb (read (strcat "point_" (itoa i))) prev_symb (read (strcat "point_" (itoa (1- i)))) cur_y (cadr (eval cur_symb)) prev_y (cadr (eval prev_symb)) ) (if (> cur_y prev_y) (progn (setq point (eval prev_symb)) (set prev_symb (eval cur_symb)) (set cur_symb point) (if (/= i 2) (setq i (1- i))) ) (setq i (1+ i)) ) ) ) ``` -------------------------------- ### Command Line Usage Example (AutoLISP) Source: https://www.afralisp.net/autolisp/tutorials/polyline-bulges-part-1.php Demonstrates how to use the getPolySegs and getArcInfo functions from the AutoCAD command line. First, call getPolySegs to get the polyline segments, then use nth to select a specific segment and pass it to getArcInfo. ```autolisp Command: (setq myPoly (getPolySegs)) Select polyline: [select a polyline] ``` ```autolisp Command: (getArcInfo (nth 1 myPoly)) ``` -------------------------------- ### Coordinate Output Example Source: https://www.afralisp.net/autolisp/tutorials/into-the-database.php Example of the coordinate list returned after extraction. ```AutoLISP (400.378 621.82 0.0) ``` -------------------------------- ### Blank Drawing Setup Function Source: https://www.afralisp.net/autolisp/tutorials/drawing-setup-part-2.php Configures drawing system variables, calculates limits, and inserts a template drawing. ```AutoLISP (defun blank () ;Define function (setvar "DIMSCALE" #DWGSC) ;Set Dimscale (setvar "USERR1" #DWGSC) ;Store Scale for future (setvar "LTSCALE" ( #DWGSC 10)) ;Set Ltscale (setvar "REGENMODE" 1) ;Regen ON (setvar "TILEMODE" 1) ;Tilemode ON (setq n ( 3.5 #DWGSC)) ;Store Text Height (setq L (list ( X #DWGSC) ( Y #DWGSC)) ;Calculate Limits ) (command "LIMITS" "0,0" L "ZOOM" "W" "0,0" L "STYLE" "italict" "italict" N "" "" "" "" "" "INSERT" SIZE "0,0" #DWGSC "" "" ) ;Set Up Drawing (prompt "\n ") ;Blank Line (prompt "\nOK Setup Routine Complete") ;Inform User (princ) ;Exit Quietly ) ;End Function ``` -------------------------------- ### Load Custom Utilities via S::STARTUP Source: https://www.afralisp.net/autolisp/tutorials/redefining-commands.php Ensures custom AutoLISP routines are loaded automatically when AutoCAD starts. ```AutoLISP (defun S::STARTUP () (prompt "\nAfraLisp Custom Utilities Loaded....\n") (load "REDEFS" "\nREDEFS.LSP not found") (princ) );defun ``` -------------------------------- ### Implementing Global Variable Utilities Source: https://www.afralisp.net/autolisp/tutorials/saving-system-variables.php Example of how to integrate the global varget and varset functions into a standard routine. ```AutoLISP (defun c:example () (varget) ;store system variables and then reset them Programme statements… (varset) ;restore system variables (princ) );defun ;****************************************************** ``` -------------------------------- ### Example MainList Structure in AutoLISP Source: https://www.afralisp.net/autolisp/tutorials/efficient-variables.php This example shows the potential structure of the 'MainList' variable after items have been added using the 'AList' function. It contains both point data and system variable settings. ```autolisp (("FourthPoint" 456.598 514.007 0.0) ("ThirdPoint" 676.92 293.827 0.0) ("SecondPoint" 1030.95 526.155 0.0) ("FirstPoint" 576.636 732.669 0.0) ("OLDECHO" . 0) ("OLDHIGH" . 1) ("OLDSNAP" . 32)) ``` -------------------------------- ### Efficient List Routine Example Source: https://www.afralisp.net/autolisp/tutorials/efficient-variables.php A complete routine demonstrating the use of helper functions to manage variable storage efficiently. ```AutoLisp (defun c:efflist ( / AnItem item MainList) (setq AnItem (getvar "OSMODE")) ;get the snap setting (AList "OLDSNAP" AnItem) ;add it to the list (setq AnItem (getvar "HIGHLIGHT")) ;get the highlight setting (AList "OLDHIGH" AnItem) ;add it to the list (setq AnItem (getvar "CMDECHO")) ;get the command echo setting (AList "OLDECHO" AnItem) ;add it to the list (setvar "Osmode" 32) ;reset snap to intersection (setvar "Highlight" 0) ;switch off highlight (setvar "Cmdecho" 0) ;switch off command echo (setq AnItem (getpoint "\nSelect First Point : ")) ;get the first point (AList "FirstPoint" AnItem) ;add it to the list (setq AnItem (getpoint AnItem "\nSelect Second Point : ")) ;get the second point (AList "SecondPoint" AnItem) ;add it to the list (setq AnItem (getpoint AnItem "\nSelect Third Point : ")) ;get the third point (AList "ThirdPoint" AnItem) ;add it to the list (setq AnItem (getpoint AnItem "\nSelect Fourth Point : ")) ;get the fourth point (AList "FourthPoint" AnItem) ;add it to the list (command "Line" (RList "FirstPoint") (RList "SecondPoint") (RList "ThirdPoint") (RList "FourthPoint") "C" ) ;retrieve all the point values and draw the shape (setvar "OSMODE" (RList "OLDSNAP")) ;retrieve and reset snap ``` -------------------------------- ### Define Architectural Setup Function Source: https://www.afralisp.net/autolisp/tutorials/drawing-setup-part-3.php Defines the 'arch' function in AutoLISP, which sets up drawing variables like DIMSCALE, USERR1, LTSCALE, REGENMODE, and TILEMODE, and then calls the common drawing setup commands. ```autolisp (defun arch () ;Define function (setvar "DIMSCALE" #DWGSC) ;Set Dimscale (setvar "USERR1" #DWGSC) ;Store Scale for future (setvar "LTSCALE" ( #DWGSC 10)) ;Set Ltscale (setvar "REGENMODE" 1) ;Regen ON (setvar "TILEMODE" 1) ;Tilemode ON (setq n ( 3.5 #DWGSC)) ;Store Text Height (setq L (list ( X #DWGSC) ( Y #DWGSC))) ;Calculate Limits ) (command "LIMITS" "0,0" L "ZOOM" "W" "0,0" L "STYLE" "italict" "italict" N "" "" "" "" "" "INSERT" SIZE "0,0" #DWGSC "" "" ) ;Set Up Drawing (prompt "\n ") ;Blank Line (prompt "\nO.K Setup Routine Complete") ;Inform User (princ) ;Exit Quietly ) ;End Function ``` -------------------------------- ### Command Output Example Source: https://www.afralisp.net/autolisp/tutorials/polyline-bulges-part-2.php Example output displayed in the AutoCAD command line when running the polyarcs command. ```text Command: polyarcs Select polyline: Segment 2: Included angle: 2.9932 rad (171.4974 degrees) Height of arc: 1.1422 Chord length: 2.4605 Radius of arc: 1.2336 Center of arc: -9.4965,14.9290 Segment 4: Included angle: 0.9844 rad (56.3997 degrees) Height of arc: 0.4201 Chord length: 3.3447 Radius of arc: 3.5390 Center of arc: -5.8690,19.3390 Segment 5: Included angle: 1.6177 rad (92.6872 degrees) Height of arc: 0.5787 Chord length: 2.7043 Radius of arc: 1.8689 Center of arc: -2.1545,17.4054 ``` -------------------------------- ### nentsel Output Example Source: https://www.afralisp.net/autolisp/tutorials/polylines-and-blocks.php Sample output returned by nentsel when selecting a vertex. ```AutoLISP Select object: ((-1 . ) (0 . "POLYLINE") (5 . "270") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDb3dPolyline") (66 . 1) ``` -------------------------------- ### Entity List Examples Source: https://www.afralisp.net/autolisp/tutorials/quick-start.php Examples of entity data structures stored in the AutoCAD database. ```AutoLISP ( - 1 ) (0 . "POLYLINE") (5 . "27B") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDb3dPolyline") (66 . 1) (10 0.0 0.0 0.0) (70 . 8) (40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 0) (72 . 0) (73 . 0) (74 . 0) (75 . 0)) ``` -------------------------------- ### Deeply Nested ssget Filter Example Source: https://www.afralisp.net/autolisp/tutorials/selection-set-filters.php An example of deeply nested conditional operators (XOR, OR, XOR, AND) within an ssget filter. This demonstrates complex selection logic. ```autolisp (ssget '( (-4 . "") (-4 . "xor>") (-4 . "or>") (-4 . "xor>") )) ``` -------------------------------- ### List Definition for Foreach Source: https://www.afralisp.net/autolisp/tutorials/mapcar-and-lambda.php Defines a sample list 'a' used in the foreach example. ```autolisp (setq a '(1 2 3 4 5)) ``` -------------------------------- ### Load AutoLISP via Pull Down Menu Source: https://www.afralisp.net/autolisp/tutorials/loading-autolisp-files.php Example of loading a routine from a pull-down menu, including a check to see if the routine is already loaded. ```AutoLISP ***POP12 T_Steel [Steel Menu] T_Beams [Drawing Setup]^C^C^P+ (cond ((null C:DDSTEEL) (prompt "Please Wait...")(load "DDSTEEL"))) DDSTEEL ``` -------------------------------- ### Define a basic AutoLISP function Source: https://www.afralisp.net/autolisp/tutorials/the-define-function.php The standard syntax for starting an AutoLISP routine definition. ```AutoLISP (defun C:DDSTEEL ( / t1 t2 h1 h2 ang) ``` -------------------------------- ### Example usage of getfiled Source: https://www.afralisp.net/autolisp/tutorials/locating-files.php A routine that opens a specific directory and prompts the user to select a slide file. ```AutoLISP (defun c:slv ( / sl) (setq sl (getfiled "Pick a slide to view" "C:/SLIDES/" "sld" 10 );getfiled ); (command "vslide" sl) (princ) );defun (princ) ``` -------------------------------- ### Example Layer Entity List Source: https://www.afralisp.net/autolisp/tutorials/into-the-database.php The returned entity list structure after a successful tblsearch operation. ```lisp ((0 . "LAYER") (2 . "STEEL") (70 . 64) (62 . 7) (6 . "CONTINOUS")) ``` -------------------------------- ### Example Layer Entity List from tblnext Source: https://www.afralisp.net/autolisp/tutorials/into-the-database.php The returned entity list structure after a successful tblnext operation. ```lisp ((0 . "LAYER") (2 . "PIPE") (70 . 0) (62 . 7) (6 . "CONTINUOUS")) ``` -------------------------------- ### Example Xdata Structure Source: https://www.afralisp.net/autolisp/tutorials/extended-entity-data-part-1.php Illustrates the basic structure of Extended Entity Data, showing a string value associated with the code 1000. ```autolisp ((-3 ("AFRALISP" (1000 . "Kenny is great")))) ``` -------------------------------- ### AutoLISP EQUAL Function Example Source: https://www.afralisp.net/autolisp/tutorials/conditionals.php Demonstrates the EQUAL function for comparing two expressions for equality, including an optional fuzz argument for floating-point comparisons. ```autolisp (setq a '(x y z)) (setq b '(x y z)) (setq c b) (setq m 1.123456)) (setq n 1.123457)) (equal a c) would return true. (equal c b) would return true. (equal m n) would return nil. (equal m n 0.000001) would return true. ``` -------------------------------- ### AutoLISP (repeat) Loop Example Source: https://www.afralisp.net/autolisp/tutorials/program-looping.php Use (repeat) to execute a block of code a specified number of times. The loop counter must be an integer. ```autolisp (defun c:loop () (setq pt (getpoint "\nCentre of Rotation : ")) (setq n (getint "Enter Number of Steps : ")) (repeat n (command "Rotate" "L" "" pt "20") ) (princ) ) ``` -------------------------------- ### Loop Through Selection Set Source: https://www.afralisp.net/autolisp/tutorials/quick-start.php Starts a loop that will repeat `n` times, processing each entity in the selection set `a1`. ```autolisp (repeat n ``` -------------------------------- ### Get User Input Point in AutoLISP Source: https://www.afralisp.net/autolisp/tutorials/list-manipulation.php Prompts the user to select a point in the drawing and stores it as a list of coordinates. This is a common starting point for many AutoLISP routines. ```autolisp (setq pt1 (getpoint "\nChoose a Point : ")) ``` -------------------------------- ### Calculate a Point using Polar Source: https://www.afralisp.net/autolisp/tutorials/the-basics-part-3.php Example of calculating a point p2 relative to an insertion point ip using the polar function. ```AutoLisp (setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl))) ``` -------------------------------- ### Get Arc Information from Segment (AutoLISP) Source: https://www.afralisp.net/autolisp/tutorials/polyline-bulges-part-1.php This function calculates and prints geometric information about an arc segment, given a list containing its start vertex, bulge value, and end vertex. It handles cases where the segment is a straight line (bulge = 0.0) to prevent errors. Ensure the input segment is valid and has a non-zero bulge for arc calculations. ```autolisp (defun getArcInfo (segment / a p1 bulge p2 c c|2 gamma midp p phi r r2 s theta) ;; assign variables to values in argument (mapcar 'set '(p1 bulge p2) segment) ;; find included angle ;; remember that bulge is negative if drawn clockwise (setq theta (* 4.0 (atan (abs bulge)))) ;; output included angle (princ (strcat "\n Included angle: " (rtos theta) " rad (" (angtos theta 0) " degrees)" ) ) ;; find height of the arc (setq c (distance p1 p2) s (* (/ c 2.0) (abs bulge)) ) ;; output height of arc (princ (strcat "\n Height of arc: " (rtos s))) ;; output chord length (princ (strcat "\n Chord length: " (rtos c))) ;; If this function is used without making sure that the segment ;; is not simply a line segment (bulge = 0.0), it will produce ;; a division-by-zero error in the following. Therefore we want ;; to be sure that it doesn't process line segments. (cond ((not (equal bulge 0.0 1E-6)) ;; find radius of arc ;; first find half the chord length (setq c|2 (/ c 2.0) ;; find radius with Pythagoras (used as output) r (/ (+ (expt c|2 2.0) (expt s 2.0)) (* s 2.0)) ;; find radius with trigonometry r2 (/ c|2 (sin (/ theta 2.0))) ) (princ (strcat "\n Radius of arc: " (rtos r))) ;; find center point of arc with angle arithmetic ;; (used as output) (setq gamma (/ (- pi theta) 2.0) phi (if (>= bulge 0) (+ (angle p1 p2) gamma) (- (angle p1 p2) gamma) ) p (polar p1 phi r) ) ;; find center point of arc with Pythagoras (setq a (sqrt (- (expt r 2.0) (expt c|2 2.0))) midp (polar p1 (angle p1 p2) c|2) p2 (if (>= bulge 0) (polar midp (+ (angle p1 p2) (/ pi 2.0)) a) (polar midp (- (angle p1 p2) (/ pi 2.0)) a) ) ) ;; output coordinates of center point (princ (strcat "\n Center of arc: " (rtos (car p)) "," (rtos (cadr p)) ) ) ) (T (princ "\n Segment has no arc info")) ) (princ) ) ``` -------------------------------- ### Playback commands using (eval) Source: https://www.afralisp.net/autolisp/tutorials/the-eval-function.php Shows how to store commands in a list and execute them using (eval). ```AutoLisp (setq lst '(command "circle" pt2 rad)) (eval lst) ``` -------------------------------- ### Create a basic selection set with ssget Source: https://www.afralisp.net/autolisp/tutorials/selection-sets.php Use ssget without arguments to allow the user to select entities using any method. ```autolisp (setq sel1 (ssget)) ``` -------------------------------- ### Create a List with (list) Source: https://www.afralisp.net/autolisp/tutorials/mapcar-and-lambda.php Demonstrates two ways to create a list in AutoLISP: using the (list) command or using quote with parentheses. ```autolisp (setq a (list 1 2 3 4 5)) ``` ```autolisp (setq a '(1 2 3 4 5)) ``` -------------------------------- ### AutoLISP OR Logical Operator Example Source: https://www.afralisp.net/autolisp/tutorials/conditionals.php An example showcasing the OR logical operator to check if user input for gender is either 'y' or 'Y', printing a corresponding greeting. ```autolisp (defun c:testor () (setq a (getstring "\nAre you Male? Y/N : ")) (if (or (= a "y") (= a "Y") );or (prompt "\nHello Sir") (prompt "\nHello Madam") );if (princ) );defun (princ) ``` -------------------------------- ### Load and Display Dialogue Box in AutoLISP Source: https://www.afralisp.net/autolisp/tutorials/drawing-setup-part-1.php This AutoLISP function, C:SETUP2, loads and displays a custom dialogue box. It initializes system variables, loads the DCL file, and handles user interactions with radio buttons and the accept/cancel buttons. ```autolisp (defun C:SETUP2 () (setvar "BLIPMODE" 0) (setvar "CMDECHO" 0) (setvar "OSMODE" 0) (setq typ "e") (setq dcl_id (load_dialog "setup2.dcl")) (if (not (new_dialog "setup2" dcl_id) ) (exit) ) (set_tile "rb1" "1") (action_tile "rb1" "(setq typ \"e\") (mode_tile \"eb1\" 2)") (action_tile "rb2" "(setq typ \"a\") (mode_tile \"eb1\" 2)") (action_tile "rb3" "(setq typ \"c\") (mode_tile \"eb1\" 2)") (action_tile "rb4" "(setq typ \"el\") (mode_tile \"eb1\" 2)") (action_tile "rb5" "(setq typ \"b\") (mode_tile \"eb1\" 2)") (set_tile "rb6" "1") (set_tile "eb1" "1") (mode_tile "eb1" 2) (action_tile "rb6" "(setq siz \"A0\") (mode_tile \"eb1\" 2)") (action_tile "rb7" "(setq siz \"A1\") (mode_tile \"eb1\" 2)") (action_tile "rb8" "(setq siz \"A2\") (mode_tile \"eb1\" 2)") (action_tile "rb9" "(setq siz \"A3\") (mode_tile \"eb1\" 2)") (action_tile "rb10" "(setq siz \"A4\") (mode_tile \"eb1\" 2)") (action_tile "cancel" "(done_dialog)(setq userclick nil)") (action_tile "accept" (strcat "(progn (setq #dwgsc (atof (get_tile \"eb1\")))" "(done_dialog) (setq userclick T))" ) ) (start_dialog) (unload_dialog dcl_id) (princ) ) (princ) ``` -------------------------------- ### Get Entity Data for Target Layer Source: https://www.afralisp.net/autolisp/tutorials/quick-start.php Retrieves the entity data list for the entity selected in `a2` and assigns it to `b2`. This is used to get the layer information. ```autolisp (setq b2 (entget (car a2))) ``` -------------------------------- ### Create Entities Source: https://www.afralisp.net/autolisp/tutorials/polylines-and-blocks.php Compare standard command-based drawing with direct entity creation using entmake. ```AutoLISP (command "Line" pt1 pt2 "") ``` ```AutoLISP (setq e '((0 . "LINE")(8 . "0")(10 50.0 50.0 0.0)(11 100.0 100.0 0.0))) (entmake e) ```