Could someone tell me what is wrong with this code?

Could someone tell me what is wrong with this code?

Anonymous
Not applicable
740 Views
1 Reply
Message 1 of 2

Could someone tell me what is wrong with this code?

Anonymous
Not applicable

;BOLT3D.LSP
;A. Belk
;This program draws a 3D bolt with round head with rectangular
; with a portion of shank without threads, from a diameter of head
; of head, length of shank, length of threaded portion, diameter
; and center point informatuon input by the user.
;
;Define the bolt command
(defun c:bolt3d()
(setq sblip(getvar "blipmode"))
(setq smde(getvar "cmdecho"))
(setq snp(getvar "osmode"))
(setq 3dosmde(getvar "3dosmode"))
(setq dyucs(getvar "ucsdetect"))
(setvar "blipmode" 0)
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setvar "3dosmode" 0)
(setvar "ucsdetect" 0)

(setq A "y")

(while (or (= A "y") (= A"Y"))

;Ask user for data of bolt
;Input D1,L1,D2,L2,L3
(setq D1 (getreal "\nDiameter of Bolt Head"))
(setq L1 (getreal "\nHeight of Bolt Head"))
(setq L2 (getreal "\nLength of Shank of Bolt"))
(setq L3 (getreal "\nLength of Threaded Portion of Shank of the Bolt"))
(setq D2 (getreal "\nDiameter of the Shank"))
(setq pt1 (getpoint "\nLocate Center Point in the XY Plane at the Bottom of the Bolt Head"))
(setq R1 (/ D1 2))
(setq R2 (/ D2 2))
(setq R3 (/ (* R1 1.09) 0.6))
(setq pt2 (list (+ (car pt1) (/ (* D1 0.1) 2)) (cadr pt1) (caddr pt1)))
(setq pt3 (list (car pt1) (cadr pt1) (+ (caddr pt1) (/ (L1) 2))))
(setq pt4 (list (car pt1) (cadr pt1) (- (caddr pt1) (- (L2) L3))))
(setq pt5 (list (- (car pt1) (/ (* (D1) 0.1) 2)) (- (cadr pt1) sqrt(- (exp((/ (R3) 2) 2)) (exp (/ (* (D1) 0.1) 2) 2))) (- (+ (caddr pt1) L1) (* D1 0.16))))
(setq pt6 (list (+ (car pt5) (* (D1) 0.1) (+ (cadr pt5) sqrt(- (exp R3 2) (exp (* D1 0.1) 2))) (+ (+ (caddr pt5) (+ (L1) 0.1)) (* D1 0.16)))))
(setq L4 (+ L1 R1))
(command "cylinder" pt1 pt2 L4)
(setq el (entlast))
(command "sphere" pt3 R3)
(command "intersect" el "l" "")
(setq e2 (entlast))
(command "cylinder" pt1 pt2 L1)
(command "union" e2 "l" "")
(setq e3 (entlast))
(command "box" pt5 pt6)
(command "subtract" e3 "" "l" "")
(setq e4(entlast))

(setq A(getstring "\nDo You want to create another bolt (y or n)"))
)
;close while loop

(command "ucs" "w")
(command "VPOINT" (list 1 -1 1))
;change to isometric view

(command "hide")
(setvar "blipmode" sblip)
(setvar "cmdecho" smde)
(setvar "osmode" snp)
(setvar "3dosmode" 3dosmde)
(setvar "ucsdetect" dyucs)
)

;Save current state of blipmode. command echo and osnap and turn

0 Likes
741 Views
1 Reply
Reply (1)
Message 2 of 2

Ranjit_Singh
Advisor
Advisor

This has come up before. See if the responses in that thread help.

0 Likes