Write a lisp function in autocad to generate theL-shape block shown below. Here is my code for
Question:
Write a lisp function in autocad to generate theL-shape block shown below.
Here is my code for that:(defun c:lbox ();Turn command echo, blipmode, etc, off (setq scmde (getvar "cmdecho")) (setvar "cmdecho" 0) (setq sblip (getvar "blipmode")) (setvar "blipmode" 1) (setq sosmd (getvar "osmode")) (setvar "osmode" 0) (setq 3dosmd (getvar "3dosmode")) (setvar "3dosmode" 0) (setq dyuos (getvar "ucsdetect")) (setvar "ucsdetect" 0)
;Ask User for Inputs (setq pt1 (getpoint "Locate Upper Left CornerPoint")) (setq pt2 (getpoint "Locate Lower right CornerPoint")) (setq H (getreal "Input height of Object")) (setq D (getreal "Input Diameter of the Cylinder"))
;Create the Object ;Define Points For Object (command "color" "red") (setq pt3 (list (car pt1) (cadr pt1) (- H))) (setq pt4 (list (car pt2) (cadr pt2) (- A H))) ;Or-H-A (setq pt5 (list (+ (car pt3) H) (cadr pt3) (caddrpt3))) (setq pt6 (list (car pt1) (/ (+ (cadr pt2) (cadr pt1)) 2) (/(caddr pt4) 2))) (setq pt7 (list (+ (car pt6) A) (cadr pt6) (caddrpt6)))
;Connect the Points (command "box" pt2 pt3) (setq e1 (entlast)) ; Create for Union (command "box" pt4 pt5) (command "union" e1 "l" "") ;Union, "" = enter (setq e2 (entlast)) (command "color" "green") (command "cylinder" pt6 (D 2) "A" pt7) (command "subtract" e2 "" "l" "")
;Print The Name On the Front Surface of Object (command "color" "blue") (command "ucs" 3 pt3 pt5 pt1) (command "text" (list 1 1) 0.5 0 "Name")
;Change the View fro Top to SE ISO (command "ucs" "w") (command "vpoint" (list 1 -1 1)) (command "hide") ;remove hidden line;Return commmand echo, blipmode. etc. Back to original (setvar "cmdecho" scmde) (setvar "blipmode" sblip) (setvar "osmode" sosmd) (setvar "3dosmode" 3dosmd) (setvar "ucsdetect" dyucs)
)
The error I am getting when compile in autocad is argumenttype:numberp:nil. Can somebody help me fix the lip function here sothe function generates the LBOX? Thank you for your help !!
Managerial accounting
ISBN: 978-0471467854
1st edition
Authors: ramji balakrishnan, k. s i varamakrishnan, Geoffrey b. sprin