2018年7月29日 星期日

2018年7月27日 星期五

(DEFUN C:ttp()
(setvar "BLIPMODE" 0)
(setq OSM (getvar "osmode"))
(setvar "osmode" 0)
(setq en (entget (car(entsel "Please choose circle 1:\n "))))
(setq cp1 (cdr (assoc 10 en)))
(setq r1 (cdr (assoc 40 en)))
(setq en (entget (car(entsel "Please choose circle 2:\n "))))
(setq cp2 (cdr (assoc 10 en)))
(setq r2 (cdr (assoc 40 en)))
(setq en (entget (car(entsel "Please choose circle 3:\n "))))
(setq cp3 (cdr (assoc 10 en)))
(setq r3 (cdr (assoc 40 en)))

(setq ang1 (angle cp3 cp1))
(setq ang2 (angle cp3 cp2))
(setq test 1)
 (while (>= test 0.001)
  (setq p1 (polar cp3 ang1 r3))
  (setq d1 (- (distance p1 cp1) r1))
  (setq d2 (+ (distance p1 cp2) r2))
  (setq test (abs (- d1 d2)))
  (setq ang1 (+ ang1 0.00001))
;  (princ ang1)
  )
(setq ang1 (angle p1 cp1))
(setq ang2 (angle p1 cp2))
(setq p2 (polar p1 ang1 d1))
(setq p3 (polar p1 ang2 d1))
(command "ARC" "C" p1 p2 p3)
(setvar "osmode" OSM)
)

2012年9月27日 星期四

任一轉角正方形

(DEFUN C:rect()
(SETVAR "CMDECHO" 0)
(SETQ DIS (GETDIST "\n Width:"))
(SETQ CL (GETVAR "CLAYER"))
(SETQ ANG (GETreal "\n Rotate Angle: "))
(SETQ SP (GETPOINT "\nPICK LOWER LEFT CORNER :"))
(SETQ P2 (POLAR SP (DTR ANG) DIS))
(SETQ P3 (POLAR P2 (DTR (+ ANG 90.0)) DIS))
(SETQ P4 (POLAR P3 (DTR (+ ANG 180.0)) DIS))
(COMMAND "LAYER" "M" "DOOR" "C" "YELLOW" "" "")
(COMMAND "LINE" SP P2 P3 P4 "C")
(SETVAR "CLAYER" CL)
)


(DEFUN DTR (a)
(* Pi (/ a 180.0))
)

(PRINC)

同心圓

(defun C:SYCIRCLE()
(setq CT (getpoint "Enter Circle's Center point:"))
(setq I 1)
(setq R (* I 0.25))
(while (<= I 10)
(Command "CIRCLE" CT R)
(setq I (1+ I))
(setq R (* I 0.5))
)
)
(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)
(setq SA 0)
(repeat 6
(princ)
(command "ARC" "C" (POLAR CP (DTR SA) RA) (POLAR CP (DTR (+ SA 60)) RA) (POLAR CP (DTR (- SA 60)) RA))(setq SA (+ SA 60)))
(setvar "osmode" OSM)
)
(DEFUN DTR (a)
(* Pi (/ a 180.0))
)

秒針轉動

(defun C:chp()
(setq ps (cdr (assoc 10 (entget (entlast)))))
(setq pe (cdr (assoc 11 (entget (entlast)))))
(setq L (distance ps pe))
(setq n 1)
(repeat 12

(repeat 500000
(princ)
)



(setq pxn (+ (car ps) (* L (cos (- (/ pi 2.0) (* (/ pi 6) n))))))
(setq pyn (+ (cadr ps) (* L (sin (- (/ pi 2.0) (* (/ pi 6) n))))))
(setq npt (list 11 pxn pyn 0))
(entmod (subst npt (assoc 11 (entget (entlast))) (entget (entlast))))
(setq n (+ n 1))


)
)
(defun C:chp()
(setq ps (cdr (assoc 10 (entget (entnext)))))
(setq pe (cdr (assoc 11 (entget (entnext)))))
(setq L (distance ps pe))
(setq ps1 (cdr (assoc 10 (entget (entlast)))))
(setq pe1 (cdr (assoc 11 (entget (entlast)))))
(setq L1 (distance ps1 pe1))
(setq n 1)(repeat 12

(repeat 500000 (princ))

(setq pxn (+ (car ps) (* L (cos (- (angle ps pe) (* (/ pi 6) n))))))
(setq pyn (+ (cadr ps) (* L (sin (- (angle ps pe) (* (/ pi 6) n))))))
(setq npt (list 11 pxn pyn 0)) (setq npt1 (list 10 pxn pyn 0))
(entmod (subst npt (assoc 11 (entget (entnext))) (entget (entnext))))
(entmod (subst npt1 (assoc 10 (entget (entlast))) (entget (entlast))))
(setq n (+ n 1))
)
)