CommaCommand to draw a tapped hole, top and side and add dimension

CommaCommand to draw a tapped hole, top and side and add dimension

Anonymous
Not applicable
2,500 Views
22 Replies
Message 1 of 23

CommaCommand to draw a tapped hole, top and side and add dimension

Anonymous
Not applicable
;;Command to draw a tapped hole, top and side and add dimension.
;;
;;1) need help, how can we make "dimpost" a variable that fills in the dim dia?
;;2) want to make the pattern below work with a several different hole sizes
;;thanks for any help, Steve
 
(defun c:th3 ()
;;;(SETQ a (/(getreal "\nEnter Tap Dia :")2))
;;;(SETQ b (/(getreal "\nEnter Drill Size :")2))
(SETQ a 0.125) ;radius of .250 dia threads
(SETQ b 0.1005) ;radius of .201 dia thru hole
(SETVAR "DIMPOST" "\\P\ <>-20 TAP \\P\.201 DRILL")
(SETQ P (GETPOINT "\SELECT center point"))
(setq c1 (car P));x
(setq c2 (cadr P));Y
(setq xl (- c1 a))
(setq xr (+ c1 a))
(setq cpd (-(- c2 a)a))
(setq xdl (- c1 b))
(setq xdr (+ c1 b))
(setq sc (* 0.707106781 a)) ;trig for sin and csin
(setq lx (- c1 sc))
(setq ly (- c2 sc))
(SETQ SC1 (+(* 1.4 a)C1)) ;POINT X 90° OF P
(setq dir1 (polar p -100 (+ a 1.0)));
(setq dir2 (polar p 0 a))
(setq p1 (list xl cpd));xy left tap
(setq p2 (list xr cpd));xy right tap
(setq p3 (list c1 cpd));xy center
(setq p4 (list xdl cpd));xy left drill
(setq p5 (list xdr cpd));xy right drill
(setq p6 (list lx ly));POINT 45° AT A RAD
(setq p7 (list SC1 C2));POINT 90° OF P XY
(command "_circle" P b "")
(command "_line" p1 "@0.0, -2.0" "")
(command "_change" "last" ""  "p" "lt" "HIDDEN2" "")
(command "_line" p2 "@0.0, -2.0" "")
(command "_change" "last" ""  "p" "lt" "HIDDEN2" "")
(command "_line" p3 "@0.0, -2.0" "")
(command "_change" "last" ""  "p" "lt" "CENTER2" "")    
(command "_line" p4 "@0.0, -2.0" "")
(command "_line" p5 "@0.0, -2.0" "")
(command "_.ARC" "C" "_non" p "_non" (polar p (angtof "22.5") A) "_non" (polar p (angtof "67.5") A))
(command "_array" "LAST" "" "polar" p "4" "360" "y")
(command "_line" p P7 ""); drawl line for cross hairs
(command "_array" "LAST" "" "polar" p "4" "360" "y"); cross hairs
(command "_DIMDEC" 3)
(command "circle" p a "") ;draw circle
(setq h (entlast));get last ent
(command "dimdiameter"  dir2 dir1) ;dim circle
(command "erase" h "") ;erase circle
(command "_line" p P7 "")
(command "_arraypolar" "LAST" "" p "A" "90" "I" "4" "")
(SETVAR "DIMPOST" "<>")
)
0 Likes
2,501 Views
22 Replies
Replies (22)
Message 21 of 23

Anonymous
Not applicable

Kent, thanks, that was what I was missing!

revised code, also added a depth of hole.

Want to add drill point option of angle 118 deg or 135 deg,

any suggestions?

_hole-thd-dim-07.JPG

 

;;command to draw a .250-20 tapped thru hole, top and side with a dynamic label.

(defun c:th7 ()
;;(SETQ a (/(getreal "\nEnter Tap Dia :")2))
;;(SETQ b (/(getreal "\nEnter Drill Size :")2))

(SETQ a 0.125) ;radius of .250 dia threads
(SETQ b 0.1005) ;radius of .201 dia thru hole
(SETQ depth (getreal "\nEnter Drill depth :"))

(SETQ P (GETPOINT "\SELECT center point"))
(setq c1 (car P));x
(setq c2 (cadr P));Y
(setq xl (- c1 a))
(setq xr (+ c1 a))
(setq cpd (-(- c2 a)a))
(setq xdl (- c1 b))
(setq xdr (+ c1 b))
(setq sc (* 0.707106781 a)) ;trig for sin and csin
(setq lx (- c1 sc))
(setq ly (- c2 sc))
(SETQ SC1 (+(* 1.4 a)C1)) ;POINT X 90° OF P
(setq dir1 (polar p -100 (+ a 2.0)));
(setq dir2 (polar p 0 a))
(setq p1 (list xl cpd));xy left tap start point
(setq p2 (list xr cpd));xy right tap start point
(setq p3 (list c1 cpd));xy center start point
(setq p4 (list xdl cpd));xy left drill start point
(setq p5 (list xdr cpd));xy right drill start point
(setq p6 (list lx ly));POINT 45° AT A RAD
(setq p7 (list SC1 C2));POINT 90° OF P XY

(command "_circle" P b )

;(command "_line" p4 "@0.0, -2.0" "") ;draw vertical left line for hole
(command "_line" p4 (strcat "@" (rtos DEPTH) "<" (itoa 270)) "")

;(command "_line" p5 "@0.0, -2.0" "") ;draw vertical right line for hole
(command "_line" p5 (strcat "@" (rtos DEPTH) "<" (itoa 270)) "")

;(command "_line" p1 "@0.0, -2.0" "") ;draw vertical left line for tapped hole
(command "_line" p1 (strcat "@" (rtos DEPTH) "<" (itoa 270)) "")
(command "_change" "last" "" "p" "lt" "HIDDEN2" "")

;(command "_line" p2 "@0.0, -2.0" "") ;draw vertical right line for tapped hole
(command "_line" p2 (strcat "@" (rtos DEPTH) "<" (itoa 270)) "")
(command "_change" "last" "" "p" "lt" "HIDDEN2" "")

;(command "_line" p3 "@0.0, -2.0" "") ;draw vertical center line for hole
(command "_line" p3 (strcat "@" (rtos DEPTH) "<" (itoa 270)) "")
(command "_change" "last" "" "p" "lt" "CENTER2" "")

(command "_line" p P7 "") ;draw line for cross hairs
(command "_array" "LAST" "" "polar" p "4" "360" "y"); cross hairs

(command "circle" p a "" "") ;draw circle for threads
(command "_change" "last" "" "p" "lt" "HIDDEN2" "")

(command "dimdiameter" dir2  "T" (strcat
"\\P""\\P" (rtos (* b 2) 2 3) " DIA HOLE (#7)"
"\\P" (rtos depth 2 2) " +/-.020 DEEP"
"\\P" (rtos (* a 2) 2 3) "-20 UNC-2B"
); strcat
dir1
)

;;dir2 dir1 "" ) ;dim circle
;;(SETVAR "DIMPOST" "<>")

)
(princ "\nType th7 to Run ")

 

 

 

0 Likes
Message 22 of 23

Sea-Haven
Mentor
Mentor

Still think better to look at a dcl input did the enter values add tolerance to code I provided for you can have also BSW UNC UNF choice as radio buttons. 

0 Likes
Message 23 of 23

Anonymous
Not applicable

revised code,

added drill point

 

_hole-thd-dim-08.JPG

 

;;command to draw a .250-20 tapped thru hole, top and side with a dynamic label.

(defun c:th8()

(setq down1 (getreal "\nEnter drill depth :"))
(setq INSPOINT (getpoint "\nPick start point :"))

(setq bb 0.201);dia
(setq aa 0.250);DIA

(setq a (/ aa 2));RAD
(setq b ( / bb 2));RAD
(setq head 0.250);height
(setq an (* b 0.600860619));tan 31° x rad

(setq pit (- down1 (* 3.5 0.05)));pitch of threads

(setq c1 (car INSPOINT));x
(setq c2 (cadr INSPOINT));Y
(setq xl (- c1 a))
(setq xr (+ c1 a))

(setq cpd (- c2 (* a 4)))
(setq xdl (- c1 b))
(setq xdr (+ c1 b))
(SETQ SC1 (+(* 1.4 a)C1)); POINT X 90° OF P
(setq dir2 (polar INSPOINT 0 a))
(setq dir1 (polar INSPOINT (angtof "30") (+ a  2.0)))

(setq an1 (- cpd (+ down1 an)))

(setq p1 (list xl cpd));xy left tap
(setq p2 (list xr cpd));xy right tap
(setq p3 (list c1 cpd));xy center
(setq p4 (list xdl cpd));xy left drill
(setq p5 (list xdr cpd));xy right drill

(setq p7 (list SC1 C2)); POINT 90° OF inspoint XY

(setq p10 (list c1 an1));drill point


(command "_circle" INSPOINT b "")

;;draw vertical left line for tapped hole
(command "_line" p1 (strcat "@" (rtos pit)"<" (itoa 270)) "")
(command "_change" "last" ""  "p" "lt" "HIDDEN2" "C" "2" "")

;;draw vertical right line for tapped hole
(command "_line" p2 (strcat "@" (rtos pit)"<" (itoa 270)) "")
(command "_change" "last" ""  "p" "lt" "HIDDEN2" "C" "2" "")

;;draw vertical center line for hole
(command "_line" p3 (strcat "@" (rtos down1)"<" (itoa 270)) "")
(command "_change" "last" ""  "p" "lt" "CENTER2" "")

;;draw vertical left line for hole
(command "_line" p4 (strcat "@" (rtos down1) "<" (itoa 270)) p10  "")

;;draw vertical right line for hole
(command "_line" p5 (strcat "@" (rtos down1) "<" (itoa 270)) p10 "")

(command "_.ARC" "C" "_non" INSPOINT "_non" (polar INSPOINT (angtof "22.5") A) "_non" (polar INSPOINT (angtof "67.5") A))
(command "_array" "LAST" "" "polar" INSPOINT "4" "360" "y")

(command "_line" INSPOINT P7 ""); draw line for cross hairs
(command "_array" "LAST" "" "polar" INSPOINT "4" "360" "y"); cross hairs

(command "circle" INSPOINT a "");draw circle
(setq h (entlast));get last ent

(command "dimdiameter" dir2  "T" (strcat
"\\P""\\P" (rtos bb 2 3) " DIA HOLE (#7)"
"\\P" (rtos down1 2 2) " +/-.020 DEEP"
"\\P" (rtos aa 2 3) "-20 UNC-2B" ) dir1); command
(command "erase" h "") ;erase circle

)
(princ "\nType th8 to Run ")

0 Likes