Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

error: bad argument type: numberp: #<SUBR @000001dcc6aefb88 ->

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
1922 Views, 2 Replies

error: bad argument type: numberp: #<SUBR @000001dcc6aefb88 ->

Hi I am creating a autolisp program to make a 3d bolt, my code is as follows:


(defun c:bolt3d ()
(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 dyucs (getvar "ucsdetect"))
(setvar "ucsdetect" 0)

(setq A "y")
(While (= A "y")
(setq D1 (getreal "\nInput Diameter of bolt head: "))
(setq L1 (getreal "\nInput Height of bolt head: "))
(setq L2 (getreal "\nInput Overall length of the shank: "))
(setq L3 (getreal "\nInput Length of the threaded portion of the shank: "))
(setq D2 (getreal "\nInput Diameter of the shank: "))
(setq pt1 (getpoint "\nEnter location of center of bolt head: "))

(setq pt2 (list (car pt1) (cadr pt1) L1))
(setq R1 (/ (/ D1 2) (cos (/ pi 6))))
;(setq R2 (/ D2 2))
(setq pt3 (list (+ (car pt1) R1) (cadr pt1)))
(setq pt4 (list (car pt1) (cadr pt1) (- (- L2 L3))))
(command "cylinder" pt2 pt3 (- L1))

(setq x (- R1 (/ (* D1 0.95) 2)))
(setq y (/ (* (sin (/ pi 6)) x) (cos (/ pi 6))))
(command "chamfer" pt3 "" x y pt3 "")
(setq e1 (entlast))
(command "POLYGON" 6 pt1 "I" R1)
(command "extrude" "l" "" L1)
(command "intersect" e1 "l" "")
(setq e2 (entlast))

if (> L2 L3) (progn
(command "cylinder" pt1 D2 (- (- L2 L3));
(Command "union" e2 "l" "")
))
(setq e3 (entlast))
(command "cylinder" pt4 (* D2 0.8) (- L3));
(command "union" e3 "l" "")
(setq e4 (entlast))
(setq pt5 (list (+ (car pt1) (/ D2 2)) (cadr pt1) - L2));
(setq pt6 (list (+ (car pt1) (/ D2 2)) (cadr pt1) (+ - L2 (* D2 0.1))));
(setq pt7 (list (+ (car pt1) (/ D2 2)) (cadr pt1) (+ - L2(* D2 0.2))));
(command "3dpoly" pt5 pt6 pt7 pt5)
(command "revolve" "l" "" pt1 pt2 "")
(setq e5 (entlast))

(setq n (- fix (/ L3 (* 0.2 D2)) 1))
(while (<= i n)
(command "copy" e5 "" (list 0 0 0) (list 0 0 (* i 0.2 D2)))
(command "union" "l" e4 "")
(setq e4 (entlast))
(setq i (+ i 1))
)

(command "union" e4 e5 "")

(Setq A (getstring "/nDo you want to create another bolt (y or n)")); get string does not expect a # value
)

(command "ucs" "w")
(command "vpoint" (list 1 -1 1))
(command "hide")

(setvar "blipmode" sblip)
(setvar "cmdecho" scmde)
(setvar "osmode" snp)
(setvar "3dosmode" 3dosmd)
(setvar "ucsdetect" dyucs)
)

 

The code runs as far as creating both cylinders and then I get this error  "error: bad argument type: numberp: #<SUBR @000001dcc6aefb88 ->"

 

any suggestions? 

2 REPLIES 2
Message 2 of 3
Ranjit_Singh1
in reply to: Anonymous

see my reply here

Message 3 of 3
john.uhden
in reply to: Anonymous

You do realize that you have two (2) topics running for the same thing, right?  Please stick to one.

 

Anyway, I don't like the looks of this too much...

 

(setq pt5 (list (+ (car pt1) (/ D2 2)) (cadr pt1) - L2))

which returns a list of 4 items, the 3rd of which is '- (the function for subtraction), as in...

 

Command: (nth 2 pt5)
#<SUBR @052fd598 ->

and

Command: (eval -)
#<SUBR @052fd598 ->

 

John F. Uhden

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report