I want to draw a simple bolt using AutoLISP
I wanted to input the diameter of bolt using getreal and to load the data related to the diameter what I input already.
But Error message occured "stringp nil".
please notify me which part is wrong
Code:
(defun bolt()
(setq fo (open "C:/Bolt.txt" "r"))
(while (/= bolt_d data_bolt_1)
(setq bolt_d (getreal "Enter the diameter of bolt"))
(setq data_bolt (read-line fo))
(setq data_bolt_1 (atof (substr data_bolt 2 4)))
)
(setq bolt_l (getreal (princ (substr data_bolt 76 6))))
(setq bolt_m (atof (substr data_bolt 6 5)))
(setq bolt_b (atof (substr data_bolt 11 5)))
(setq bolt_dkmx (atof (substr data_bolt 16 5)))
(setq bolt_da (atof (substr data_bolt 21 5)))
(setq bolt_ds (atof (substr data_bolt 26 5)))
(setq bolt_e (atof (substr data_bolt 31 5)))
(setq bolt_lf (atof (substr data_bolt 36 5)))
(setq bolt_k (atof (substr data_bolt 41 5)))
(setq bolt_r (atof (substr data_bolt 46 5)))
(setq bolt_s (atof (substr data_bolt 51 5)))
(setq bolt_t (atof (substr data_bolt 56 5)))
(setq bolt_v (atof (substr data_bolt 61 5)))
(setq bolt_dw (atof (substr data_bolt 66 5)))
(setq bolt_w (atof (substr data_bolt 71 5)))
(setq pt0 '(0 0))
(setq pt1 (polar pt0 (/ pi 2) (- (/ bolt_dk 2) (bolt_v))))
(setq pt2 (polar pt1 (/ pi 4) (/ bolt_v (cos(/ pi 4)))))
(setq pt3 (polar pt2 0 (- bolt_k bolt_v)))
(setq pt4 (polar pt3 (/ pi -2) (- (/ bolt_dk 2) (/ bolt_da 2))))
(setq pt5 (list (+ bolt_lf) (- (- (/ bolt_da 2) (/ bolt_ds 2)))))
(setq pt6 (polar pt5 0 (- bolt_l (* bolt_P 2))))
(setq pt7 (polar pt6 (/ pi -4) (/ bolt_v (cos (/ pi 4)))))
(setq pt8 (polar pt7 (/ pi -2) (- (/ bolt_d 2) (* bolt_P 2))))
(setq pt9 (polar pt8 (/ pi 2) (/ bolt_dk 2)))
(command "pline" pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 "C")
(setq ss1 (ssget "C" pt7 pt8))
(command "mirror" ss1 "" pt0 pt8 "N")
)