2009年4月29日 星期三

2009年4月9日 星期四

AutoLisp homework

Input the Diameter D and a point in the work area
  • (defun C:CIR_Ex(/ )
  • (setvar "BLIPMODE" 0)
  • (setq OSM (getvar "osmode"))
  • (setvar "osmode" 0)
  • (setq CP (getpoint "\nEnter Center Point..."))
  • (setq RA (getdist CP "\nEnter Radius ..."))
  • (command "circle" CP RA)
  • (princ)
  • (command "ARC" "C" (POLAR CP (DTR 0) RA) (POLAR CP (DTR 60) RA) (POLAR CP (DTR -60) RA))
  • (setvar "osmode" OSM)
  • )
  • (DEFUN DTR (a)
  • (* Pi (/ a 180.0))
  • )

2009年4月8日 星期三

ETCIR

(defun C:ETCIR(/ EC1 EC2 TCC TCR Rt CIR DX DY)
(setvar "BLIPMODE" 0)
(setq EC1 (Osnap (getpoint "\nSelect existing circle ...") "nea"))

(setq EC2 (Osnap EC1 "center"))
(setq TCR (getdist EC1 "\n Enter Tangent Circle Radius :"))
(setvar "AUNITS" 0)
(setq Rt (getangle EC2 "\nEnter direct angle :"))
(setq CIR (distance EC1 EC2))
(setq DX (* (+ CIR TCR) (cos Rt)))
(setq DY (* (+ CIR TCR) (sin Rt)))
(setq TCC (list (+ (car EC2) DX) (+ (cadr EC2) DY)))
(command "Circle" TCC TCR)
)