home *** CD-ROM | disk | FTP | other *** search
- ;;; HOLE.lsp
- ;;; ¬⌐┼v (C) 1992 Autodesk ñ╜Ñq
- ;;;
- ;;; Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
- ;;; ¡∞½h :
- ;;;
- ;;; 1) ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
- ;;; 2) ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
- ;;;
- ;;; Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
- ;;; Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
- ;;;
- ;;;
- ;;; By Rick Barrientos
- ;;; Thanks to Levent Setzer for providing technical support.
- ;;; Version 0.6 9 March 1992
- ;;;
- ;;;----------------------------------------------------------------------------;
- ;;;
- ;;; DESCRIPTION
- ;;;
- ;;; HOLE.LSP is a sample AME 2.0 lisp routine.
- ;;;
- ;;; It allows feature based creation of countersinks and counterbores.
- ;;; It makes use of api functions called through Autolisp. It will not
- ;;; run with AME 1.0 as these functons were not supported through
- ;;; Autolisp at that time.
- ;;;
- ;;; The program is loaded and called by typing "hole". The user is then
- ;;; prompted to select a counterbore or countersink. A face with a hole
- ;;; must be selected next. This face must be planar. The edge of the
- ;;; hole to countersink or counterbore must then be selected. This must
- ;;; be a round hole and must lie on the face previously selected.
- ;;;
- ;;; To create a counterbore, the user must specify a diameter or radius
- ;;; and a depth for the feature. To create a countersink, the user
- ;;; must input a diameter or radius and an included angle.
-
- ;input parameters function
- (defun input (
- typ
- /
- loop finfo edge einfo axis check lp chk err
- )
- ;select the face
- (setq loop 1)
- (while (= loop 1)
- ;--------------------------------------
- ;check CTR-C to break out of the loop
- (if (and (null (setq face (ap_sel_face (strcat "\n┐∩╛▄ñw╞pñ╒¬║Ñ¡¡▒í╨"
- (cdr (assoc typ alist)) ": \n"))))
- (/= 45 (setq err (ap_last_errcode)))
- )
- (prompt "\n┐∩⌐w¬║║cñ╕ñú¼░íu¡▒ív; ╜╨ªA╕╒íC")
- (progn
- ;---------------------------
- (if (= 45 err)
- (setq loop 0)
- (progn
- (setq finfo (ap_get_faceinfo face))
- ;check to see that selected face is planar
- (if (/= 0 (car finfo))
- (princ "\n┐∩⌐w╣∩╢Hñú¼░íuÑ¡¡▒ív; ╜╨ªA╕╒íC\n")
- (setq loop 0)
- )
- )
- )
- )
- )
- )
-
-
-
- ;select the edge
- (if (= 45 err)
- (setq loop 0)
- (setq loop 1)
- )
-
- (while (= loop 1)
- ;check the value of variable edge
- ;---------------------------------------------
- ;check CTR-C to break out of the loop
- (if (and (null (setq edge (ap_sel_edge (strcat "\n┐∩╛▄íu╞pñ╒╜t├Σíví╨" (cdr (assoc typ alist)) ": "))))
- (/= 45 (setq err (ap_last_errcode)))
- )
- (prompt "\n┐∩⌐w¬║║cñ╕ñú¼░íu╜t├Σív; ╜╨ªA╕╒íC")
- (progn
- ;-----------------------------------------
- (if (= 45 err)
- (setq loop 0)
- (progn
- (setq einfo (ap_get_edgeinfo edge))
- ;get ru and rv
- (setq axis (nth 7 einfo))
- ;check that edge is on face
- (setq check (ap_face2edges face))
- ;check that edge round and on face
- (if (or
- (or (/= 1 (car einfo)) (/= (car axis) (cadr axis)))
- (null (member (cadr edge) check))
- )
- (Princ "\n╜t├ΣÑ▓╢╖ªb┐∩⌐w¬║íu¡▒ñ╕ívñW, ÑB└│¼░íuÑ┐╢ΩívíC\n")
- (setq loop 0)
- );if
- )
- );if
- )
- );if
- )
-
- ;-----------------------------------
- (if (/= 45 err)
- (progn
- ;get center of edge
- (setq cx (nth 3 (nth 0 (nth 4 einfo))))
- (setq cy (nth 3 (nth 1 (nth 4 einfo))))
- (setq cz (nth 3 (nth 2 (nth 4 einfo))))
- (setq cen (list cx cy cz))
-
- ;get face normal
- (setq nx (nth 0 (car (nth 3 finfo))))
- (setq ny (nth 1 (car (nth 3 finfo))))
- (setq nz (nth 2 (car (nth 3 finfo))))
-
- ;def,rdef and ddef should be global variables
- ;get Diameter of CBore/CSink
- (setq loop 1)
- (while (= loop 1)
- (setq lp 1)
- (while (= lp 1)
- (if (= def nil) (setq def "Diameter"))
- (if (= rdef nil)
- (progn
- (if (= def "Radius")
- (setq rdef (* 1.5 (car axis)))
- )
- (if (= def "Diameter")
- (setq rdef (* 3.0 (car axis)))
- )
- )
- );if
- ;prompt with hole radius
- (if (= def "Radius")
- (progn
- (princ "\n┐∩⌐w¬║íu╞pñ╒Ñb«|ív: ")
- (princ (car axis))
- )
- )
- ;prompt with hole diameter
- (if (= def "Diameter")
- (progn
- (princ "\n┐∩⌐w¬║íu╞pñ╒¬╜«|ív: ")
- (princ (* 2 (car axis)))
- )
- );if
- (if (= def "Radius") (princ "\nD¬╜«| ⌐╬ <RÑb«|> "))
- (if (= def "Diameter") (princ "\nRÑb«| ⌐╬ <D¬╜«|> "))
- (initget 6 "Radius Diameter")
- ;prompt with size of feature
- (princ "í╨") (princ (cdr (assoc typ alist))) (princ" <")
- (princ rdef)
- (princ ">: ")
- ;get feature size
- (setq rad (getdist))
- (if (= rad nil) (setq rad rdef))
- (setq rdef rad)
- (if (= rad "Radius") (setq chk "Radius"))
- (if (= rad "Diameter") (setq chk "Diameter"))
- (if (= chk "Diameter") (setq def "Diameter"))
- (if (= chk nil) (setq chk def))
- (if (= chk "Radius") (setq def "Radius"))
-
- ;ifrdef is not defined, set to one and a half times hole size
- ;if it is defined, keep definition
- (if (or (= rad "Radius") (= rad "Diameter"))
- (progn (setq rad nil) (setq rdef rad))
- (setq lp 0)
-
- );if
- );while
- ;check that CBore Diameter/Radius is larger than hole Diameter
-
- (if
- (or
- (and (= chk "Diameter") (<= rad (* 2 (car axis))))
- (and (= chk "Radius") (<= rad (car axis)))
- )
- (progn
- (princ "\n─╡ºi:") (princ (cdr (assoc def alist)))
- (princ "ñp⌐≤íuñ╒«|ívíC")
- )
- (setq loop 0)
- );if
- );while
- )
- );if
- err
- )
-
- ; function that makes the counterbore
- (defun makecb (/ px py pz p2 a)
- ;get depth of CBore
- (if (= ddef nil) (setq ddef 1.0))
- (princ "\n▓`½╫í╨") (princ (cdr (assoc typ alist))) (princ ":<")
- (princ ddef)
- (princ "> ")
- (initget (+ 2 4))
- (setq depth (getdist))
- (if (= depth nil) (setq depth ddef))
- (setq ddef depth)
-
- ;calculate endpoint of CBore
-
- (command "_.ucs" "_w")
-
- (setq px (- cx (* depth nx)))
- (setq py (- cy (* depth ny)))
- (setq pz (- cz (* depth nz)))
- (setq p2 (list px py pz))
-
- ;make CBore
-
- (if (= def "Radius") (setq b (SOLCYL cen rad "c" p2)))
- (if (= def "Diameter") (setq b (SOLCYL cen "d" rad "c" p2)))
- (setq a (ap_obj2name (car face)))
-
- (SOLSUB a b)
- (command "_.ucs" "_p")
- )
-
- ; function that makes the countersink
- (defun makecs (/ iang ang a b px py pz p2)
- ;get included angle and calculate depth of CSink
- (if (= iang nil) (setq iang 82.0))
- (princ "\n┬Xñ╒└@¿ñí╨ÑHíu½╫ív¡p <")
- (princ iang) (princ ">: ")
- (initget 6)
- (setq ang (getreal))
- (if (= ang nil) (setq ang iang))
- (setq iang ang)
- (setq a (/ ang 2))
- (if (= def "Diameter") (setq r (/ rad 2))
- (setq r rad))
- (setq depth (/ r
- (/ (sin (/ a (/ 180 pi)))
- (cos (/ a (/ 180 pi))))
- ))
- ;calculate endpoint of CSink
-
- (command "_.ucs" "_w")
-
- (setq px (- cx (* depth nx)))
- (setq py (- cy (* depth ny)))
- (setq pz (- cz (* depth nz)))
- (setq p2 (list px py pz))
-
- ;make CSink
-
- (if (= def "Radius") (setq b (SOLCONE cen rad "a" p2)))
- (if (= def "Diameter") (setq b (SOLCONE cen "d" rad "a" p2)))
- (setq a (ap_obj2name (car face)))
-
- (SOLSUB a b)
- (command "_.ucs" "_p")
- )
-
- ;option function
- ;typ is a global variable so function will remember last option
- (defun option(/ type)
-
- (initget "CSink CBore")
- (if (= typ "CSink")
- (princ "\nCBÑ¡⌐│┬Xñ╒/<CS└@º╬┬Xñ╒>: "))
- (if (/= typ "CSink")
- (progn
- (setq typ "CBore")
- (princ "\nCS└@º╬┬Xñ╒/<CBÑ¡⌐│┬Xñ╒>: ")
- )
- )
- (setq type (getkword))
- (if (= type nil) (setq type typ))
- (setq typ type)
- (if (= typ nil) (setq typ "CBore"))
-
- ;---------------------------------------------------
- ;check whether user enter CTR-C
- (if (= typ "CSink")
- (if (/= 45 (input typ))
- (makecs)
- )
- )
- ;---------------------------------------------------
- ;check whether user enter CTR-C
- (if (= typ "CBore")
- (if (/= 45 (input typ))
- (makecb)
- )
- )
- )
- ;error handler
- (defun *error* (msg)
- (princ "┐∙╗~: ")
- (princ msg)
- (princ)
- )
-
- ;main function
- (defun c:HOLE( / quit alist)
- (setq quit 0)
- (setvar "cmdecho" 0)
-
- (if (not ap_sel_face)
- (progn
- (princ "\n░⌡ªµª╣Ñ\»αñº½e, Ñ▓╢╖Ѳ╕ⁿñJ AME 2.0 ╢∞½¼╡{ªííC")
- (setq quit 1)))
-
- (if (/= quit 1) (option))
- (setvar "cmdecho" 1)
- (princ)
- )
-