;detail.lsp
;将图形中的局部区域进行放大，区域范围和放大因子可以指定。

(defun dtr (a)
 (* pi (/ a 180.00))
 )

(defun P_circle ( ang1 ang pt)
(repeat n
(setq new_ang (+ ang1 ang))
(setq ang1 new_ang)
(setq new_pt (polar pt new_ang rad))
(setq pt_list (append pt_list (list new_pt)))
)
)

(defun C:detail (/ pt_list a)
(setvar "cmdecho" 0)
(setq ltsc (getvar "ltscale"))
(command "ltscale" 0.05)
(command "regen")
(setq n 45)
(setq pt (getpoint "\n中心点： "))
(prompt "\n输入半径： ")
(command "circle" pt pause)
(setq prop1 (entget (entlast))
      rad (cdr (assoc 40 prop1))
      ang (dtr 8)
      ang1 0
      pt1 (polar pt ang1 rad))
(setq ent1 (entlast))
(p_circle ang1 ang pt)
(prompt "\n偏移的第二点： ")
(command "copy" "cp" pt1 (foreach p Pt_list (command p) "") "" pt pause)  
(setq pt_list nil)  
(setq pt (getvar "lastpoint")
 ang1 0
 ang (dtr 8)
 pt1 (polar pt ang1 rad))
 (p_circle ang1 ang pt)
(command "move" "cp" pt1 (foreach p Pt_list (command p)"") "" pt1 pt1)
(setq rad (+ rad (* 0.05 (getvar "dimscale")))
 ang1 0
 ang (dtr 12)
 n 30
 pt1 (polar pt ang1 rad)
 pt_list nil)
(p_circle ang1 ang pt)
(command "trim" "p" "" "f" pt1 (foreach p pt_list (command p) "") "")
(setq pt_list nil
      sf (getreal "\n输入比例因子："))
    (if (or(= sf nil)(= sf ""))(setq sf 1))
  (command "scale" "p" "" pt sf)
(command "text" (getvar "viewctr") (* 0.18 sf) "" (strcat "Scale factor " (rtos sf 2 1) "x"))
(prompt "\n捕捉文本到点......： ")
(command "move" (entlast) "" (getvar "viewctr") pause)
(command "erase" ent1 "")
(setvar "ltscale" ltsc)
(command "regen")
(princ)
)