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))
)
)

圖檔管理練習