
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Creating an autolisp program to add a threaded hole to a selected object, the program is as follows:
; Meghan Hendricks
; HOLETHREAD.LSP
;
(defun c:HOLETHREAD ()
(setq scmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq sblip (getvar "blipmode"))
(setvar "blipmode" 0)
(setq sosmd (getvar "osmode"))
(setvar "osmode" 0)
(setq 3dosmd (getvar "3dosmode"))
(setvar "3dosmode" 0)
(setq dyucs (getvar "ucsdetect"))
(setvar "ucsdetect" 0)
(setq ccolor (getvar "cecolor"))
(setq e1 (entsel "\nselect the object"))
(setvar "osmode" 1)
(setq pt1 (getpoint "\nEnter location of new coordinate system: "))
(setq pt2 (getpoint "\nEnter location of new x axis: "))
(setq pt3 (getpoint "\nEnter location of new y axis: "))
(command "ucs" 3 pt1 pt2 pt3)
(setvar "osmode" 0)
(setvar "blipmode" 1)
(setq pt4 (getpoint "\nEnter location of center of the hole on the surface: "))
(setvar "blipmode" 0)
(setq D1 (getreal "\nInput Diameter of the hole: "))
(setq L1 (getreal "\nInput depth of the hole (positive z direction): "))
(setq c (getstring "\nColor of hole"))
(command "color" c)
(command "cylinder" pt4 D1 L1)
(setq e2 (entlast))
(if (>= h 0)
(progn ;- z direction
(setq pt5 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) 0))
(setq pt6 (list (car pt4) (- (car pt1) D2) (- (* D1 0.1))))
(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (- (* D1 0.2))))
(setq pt8 (list (car pt4) (cadr pt4) (- (* D1 0.1))))
(command "3DPOLY" pt5 pt6 pt7 "c")
(setq e3 (entlast))
(command "helix" pt8 (* 0.4 D1)(* 0.4 D1) "H" (* 0.41 R2) (+ (* 0.4 R2) L1))
(setq e4 (entlast))
(command "sweep" e3 "" "a" "n" e4 "")
(setq e5 (entlast))
(command "subtract" e2 "" e5 "")
(setq e6 (entlast))
)
(progn ;+z direction
(setq pt5 (list (car pt4) (+ (cadr pt1) (* D2 0.4)) 0))
(setq pt6 (list (car pt4) (- (car pt1) D2) (* D1 0.1)))
(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (* D1 0.1)))
(setq pt8 (list (car pt4) (cadr pt4) (* D1 0.1)))
(command "3DPOLY" pt5 pt6 pt7 "c")
(setq e3 (entlast))
(command "helix" pt8 (* 0.4 D1)(* 0.4 D1) "H" (* 0.41 R2) (+ (* 0.4 R2) L1))
(setq e4 (entlast))
(command "sweep" e3 "" "a" "n" e4 "")
(setq e5 (entlast))
(command "subtract" e2 "" e5 "")
(setq e6 (entlast))
))
(command "subtract" e1 "" e6 "")
(command "ucs" "p")
(command "vpoint" (list 1 -1 1))
(command "vscurrent" 2) ;2d wireframe
(setvar "cecolor" ccolor)
(setvar "blipmode" sblip)
(setvar "cmdecho" scmde)
(setvar "osmode" snp)
(setvar "3dosmode" 3dosmd)
(setvar "ucsdetect" dyucs)
)
the program gets as far as creating the cylinder or diameter of D1 and then i get the error
"error: bad argument type: numberp: nil"
Solved! Go to Solution.