mitchellrodhous Posted June 17, 2010 Share Posted June 17, 2010 Hi all! Coming back on my earlier started thread below: http://www.cadtutor.net/forum/showthread.php?t=49215 First of all thanks for the help you guys gave me till now, especially from DB . A different thing is... I'm just a week started to learn making lisps so I need some explanation of the delivered lisp I became from David Bethel. (defun c:cabinet () ;MR. CAD - Mitchell Rodhouse ;Autocad The Netherlands ;define the function ;* ;Save System Variables (setq oldsnap (getvar "osmode")) ;save snap settings (setq oldblipmode (getvar "blipmode")) ;save blipmode setting (setvar "cmdecho" 0) (setvar "INSUNITS" 4) ;* ;Switch OFF system Variables (setvar "osmode" 0) ;Switch OFF snap (setvar "blipmode" 0) ;Switch OFF Blipmode ;* ;get User Inputs ;get User Inputs (setq b (getdist "\nWidth of the cabinet : ")) ;Width of the cabinet (setq h (getdist "\nHight of the cabinet : ")) ;Hight of the cabinet (setq d (getdist "\nDepth of the cabinet : ")) ;Depth of the cabinet (setq m (getdist "\nMaterialthickness of the cabinet : ")) ;Materialthicknes of the cabinet ;* ;Get Insertion Point (setq ip (getpoint "\nInsertion Point : ")) ;get the insertion point (setvar "osmode" 32) ;switch ON snap (setvar "osmode" 0) ;switch OFF snap ;* ;Start of Polar Calculations ;This are calculation made by MR Cad (setq p1 (polar ip (dtr 0.0) 0.0)) (setq p2 (polar p1 (dtr 0.0) m)) (setq p3 (polar p1 (dtr 0.0) b)) (setq p4 (polar p3 (dtr 180.0) m)) (setq p5 (polar p1 (dtr -90.0) d)) (setq p6 (polar p5 (dtr 0.0) m)) (setq p7 (polar p5 (dtr 0.0) b)) (setq p8 (polar p7 (dtr 180.0) m)) (setq p9 (list (car p1) (cadr p1) (+ (caddr p1) m))) (setq p10 (list (car p4) (cadr p4)(+ (caddr p4) m))) (setq p11 (polar p9 (dtr -90.0) d)) (setq p12 (polar p10 (dtr -90.0) d)) (setq p13 (list (car p2) (cadr p2) (+ (caddr p2) h))) (setq p14 (list (car p4) (cadr p4)(+ (caddr p4) h))) (setq p15 (polar p13 (dtr -90.0) d)) (setq p16 (polar p14 (dtr -90.0) d)) (setq p17 (list (car p13) (cadr p13) (- (caddr p13) m))) (setq p18 (list (car p14) (cadr p14) (- (caddr p14) m))) (setq p19 (list (car p15) (cadr p15) (- (caddr p15) m))) (setq p20 (list (car p16) (cadr p16) (- (caddr p16) m))) ;End of the Polar calculations by MR. CAD ;* ;Start Command Function (command "_-view" "_swiso" ) ;End command (command "ucs" "w" ) ;End command (command "box" p1 p6 h) ; (setq p1 '(10 10 0)) ; (command "_SOLID" '(10 10 0) '(20 10 0) '(10 20 0) '(20 20 0) "") (setq fe (entlast)) (setq bc 1 bn "Leftside1") (while (tblsearch "BLOCK" bn) (setq bc (1+ bc) bn (strcat "Leftside" (itoa bc)))) (entmake (list (cons 0 "BLOCK")(list 10 0 0 0)(cons 2 bn)(cons 70 2))) (entmake (entget fe)) (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 '(0 0 0)) (cons 11 '(0 0 0)) (cons 40 1) (cons 1 (strcat "(" (rtos (car p1) 2 " " (rtos (cadr p1) 2 " " (rtos (caddr p1) 2 ")")) (cons 3 "Leftside") (cons 2 "SECTION") (cons 70 0) (cons 73 0) (cons 50 0) (cons 41 1) (cons 51 0) (cons 7 "STANDARD") (cons 71 0) (cons 72 0) (cons 210 (list 0 0 1)) (cons 74 0) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER"))) (entmake (list (cons 0 "ENDBLK")(cons 8 "0"))) (entdel fe) (entmake (list (cons 0 "INSERT")(cons 2 bn)(cons 10 '(0 0 0))(cons 66 1) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER"))) (entmake (list (cons 0 "ATTRIB") (cons 8 "0") (cons 10 '(0 0 0)) (cons 11 '(0 0 0)) (cons 40 1) (cons 1 (strcat "(" (rtos (car p1) 2 " " (rtos (cadr p1) 2 " " (rtos (caddr p1) 2 ")")) (cons 2 "SECTION") (cons 70 0) (cons 73 0) (cons 50 0) (cons 41 1) (cons 51 0) (cons 7 "STANDARD") (cons 71 0) (cons 72 0) (cons 210 (list 0 0 1)) (cons 73 0) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER"))) (entmake (list (cons 0 "SEQEND")(cons 8 "0")) ) ;End Command (command "zoom" "a" ) ;End Command ;End of Commands made by MR. CAD (setvar "osmode" 32) ;switch ON snap ;* ;Reset System Variable (setvar "osmode" oldsnap) ;Reset snap (setvar "blipmode" oldblipmode) ;Reset blipmode ;* (princ) ;finish cleanly ) ;end of defun ;* ;This function converts Degrees to Radians. (defun dtr (x) ;define degrees to radians function (* pi (/ x 180.0)) ;divide the angle by 180 then ;multiply the result by the constant PI ) ;End of function ;* (princ) ;load cleanly ;* ;;HOPE THIS LISP WILL BE FUNCTIONAL FOR THE USER ;;MADE BY MR. CAD ;;END LISP Above Is shown the lisp as I created till know but from the part with following text I can´t get an clue. (cons 62 256) Can someone tell me how I use this (con °°°)? To get an explanation what I am trying to reach with this lisp read the other thread by clicking on the link above. Regards MR Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 17, 2010 Share Posted June 17, 2010 cons Adds an element to the beginning of a list, or constructs a dotted list (cons new-first-element list-or-atom) Arguments new-first-element Element to be added to the beginning of a list. This element can be an atom or a list. list-or-atom A list or an atom. Return Values The value returned depends on the data type of list-or-atom. If list-or-atom is a list, cons returns that list with new-first-element added as the first item in the list. If list-or-atom is an atom, cons returns a dotted pair consisting of new-first-element and list-or-atom. Examples Command: (cons 'a '(b c d)) (A B C D) Command: (cons '(a) '(b c d)) ((A) B C D) Command: (cons 'a 2) (A . 2) (entmake (list (cons 0 "INSERT") ;Entity Type (cons 2 bn) ;Entity Name (cons 10 '(0 0 0)) ;Insertion Point (cons 66 1) ;Variable attributes-follow flag ;(optional; default = 0); ;if the value of attributes-follow flag is 1, ;a series of attribute entities is expected to follow the insert, ; terminated by a seqend entity (cons 62 256) ;Color number (fixed) (cons 39 0) ;Entity's thickness if nonzero (fixed) (cons 6 "BYLAYER"))) ;Linetype name (fixed) Quote Link to comment Share on other sites More sharing options...
mitchellrodhous Posted June 17, 2010 Author Share Posted June 17, 2010 ok, thanks.. Now You can aspect a new question from me of course : P The code below (cons 1 (strcat "(" (rtos (car p1) 2 " " (rtos (cadr p1) 2 " " (rtos (caddr p1) 2 ")")) On what are the numbers 2 and 8 based on? Regards MR Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 17, 2010 Share Posted June 17, 2010 ok, thanks.. Now You can aspect a new question from me of course : P The code below (cons 1 (strcat "(" (rtos (car p1) 2 " " (rtos (cadr p1) 2 " " (rtos (caddr p1) 2 ")")) On what are the numbers 2 and 8 based on? Regards MR rtos Converts a number into a string (rtos number [mode [precision]]) The rtos function returns a string that is the representation of number according to the settings of mode, precision, and the system variables UNITMODE, DIMZIN, LUNITS, and LUPREC. Arguments number A number. mode An integer specifying the linear units mode. The mode corresponds to the values allowed for the LUNITS AutoCAD system variable. The mode can be one of the following numbers: 1 Scientific 2 Decimal 3 Engineering (feet and decimal inches) 4 Architectural (feet and fractional inches) 5 Fractional precision An integer specifying the precision. The mode and precision arguments correspond to the system variables LUNITS and LUPREC. If you omit the arguments, rtos uses the current settings of LUNITS and LUPREC. Return Values A string. The UNITMODE system variable affects the returned string when engineering, architectural, or fractional units are selected (mode values 3, 4, or 5). Examples Set variable x: Command: (setq x 17.5) 17.5 Convert the value of x to a string in scientific format, with a precision of 4: Command: (setq fmtval (rtos x 1 4)) "1.7500E+01" Convert the value of x to a string in decimal format, with 2 decimal places: Command: (setq fmtval (rtos x 2 2)) "17.50" Convert the value of x to a string in engineering format, with a precision of 2: Command: (setq fmtval (rtos x 3 2)) "1'-5.50\"" Convert the value of x to a string in architectural format: Command: (setq fmtval (rtos x 4 2)) "1'-5 1/2\"" Convert the value of x to a string in fractional format: Command: (setq fmtval (rtos x 5 2)) "17 1/2" Setting UNITMODE to 1 causes units to be displayed as entered. This affects the values returned by rtos for engineering, architectural, and fractional formats, as shown in the following examples: Command: (setvar "unitmode" 1) 1 Command: (setq fmtval (rtos x 3 2)) "1'5.50\"" Command: (setq fmtval (rtos x 4 2)) "1'5-1/2\"" Command: (setq fmtval (rtos x 5 2)) "17-1/2" Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2010 Share Posted June 17, 2010 Hi. first 2 means number in decimal. second 8 the quantity of decimal numbers like 1.12345678 That's all, regards, Special thanks to The Buzzard Tharwat Quote Link to comment Share on other sites More sharing options...
mitchellrodhous Posted June 17, 2010 Author Share Posted June 17, 2010 Okey Thanks both, This isn't that difficult to understand, It looks naturally. Only I am not sure what those codes have to do with making of the box, I am drawing with this lisp, and adding specific attributes on it... However that question is for discus in my other thread... Regards MR Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.