本帖最后由 dwg001 于 2012-5-1 08:19 编辑
- ;;;;dwg001 早期练习
- ;; 现小作修改
- (defun c:df (/ ang ang1-0 dimstl dist dxf ent i inter j l lay obj oldecho oldla oldmode oldsty p0 p0- p1 p2 p2- r)
-
- (setq oldmode (getvar 'osmode)
- oldla (getvar 'clayer)
- oldecho (getvar 'cmdecho)
- oldsty (getvar 'dimstyle)
- )
- (setvar 'osmode 0)
- (setvar 'cmdecho 0)
- (while (setq obj (entsel "\n...选择需等分的标注> "))
- (setq
- J (getint "\n...输入等分标注数> ")
- ent (car obj)
- dxf (entget ent)
- lay (cdr (assoc 8 dxf))
- dimstl (cdr (assoc 3 dxf))
- )
-
- (if (and obj (> J 1) (= (cdr (assoc 0 dxf)) "DIMENSION"))
- (progn
- (setq i 0
- r 0
- )
- (command "-layer" "s" lay "")
- (command "dimstyle" "r" dimstl)
- (setq P0 (cdr (assoc 10 dxf))
- P2 (cdr (assoc 13 dxf))
- P1 (cdr (assoc 14 dxf))
- )
-
-
- (setq L (distance p1 p0)
- ang1-0 (angle P1 P0)
- p0- (polar p0 (- ang1-0 (/ pi 2)) 50)
- p2- (polar p2 ang1-0 50)
- inter (inters p0 p0- p2 p2- nil))
-
-
- (if (/= L (distance p2 inter))(progn
- (setq dxf (subst
- (cons 13 (polar inter (- ang1-0 pi) L))
- (assoc 13 dxf)
- dxf ) )
- (entmod dxf)
- (setq P2 (cdr (assoc 13 dxf)))
- ) );end_ if
-
- (setq ang (angle P1 P2)
- dist (/ (distance P1 P2) J)
- P2 (polar P1 ang dist)
- )
- (command "dim1" "ali" P1 P2 P0 "")
-
- (while (< r (- J 1))
- (setq P2 (polar P2 ang dist))
- (command "dim" "con" P2 "" "e")
- (setq r (1+ r))
- )
- (setq i (1+ i))
- (entdel ent)
- )
- )
- (setvar 'clayer oldla)
- (command "dimstyle" "r" oldsty)
- )
- (princ "\n...等分标注数=")
- (princ J)
- (princ "\n...[学lisp练习: 尺寸标注等分]")
- (setvar 'osmode oldmode)
- (setvar 'cmdecho oldecho)
- (princ)
- )
|