
- [FONT=courier new]
- (defun c:d (/ p0 p1 p2 ang ent p10a p11a entst)
- (setvar "cmdecho" 0)
- (ai_undo_push)
- (setvar "osmode" 47)
- (mlay "dim" "3")
- (initget 128)
- (setq p0 (getpoint "\nSpecify first extension line origin or [Align/< Select line to align>] :")
- entst (entlast)
- )
- (if (null p0)
- (setq p0 "S")
- )
- (if (= (type p0) 'str)
- (progn
- (cond
- ((= (strcase p0) "S")
- (setq ent (nentselp "\nSelect line :"))
- (while (null ent)
- (setq ent (nentselp "\nSelect line :"))
- )
- (while (/= (cdr (assoc 0 (entget (car ent)))) "LINE")
- (setq ent (nentselp "Object selected is not line .\nSelect line :"))
- )
- (if (= (nth 3 ent) nil)
- (progn
- (setq p1 (trans (cdr (assoc 10 (entget (car ent)))) 0 1)
- p2 (trans (cdr (assoc 11 (entget (car ent)))) 0 1)
- ang (* 180 (/ (angle p1 p2) pi))
- )
- )
- (progn
- (matrix_b ent)
- (setq p1 (trans p10a 0 1)
- p2 (trans p11a 0 1)
- ang (* 180 (/ (angle p1 p2) pi))
- )
- )
- )
- )
- ((= (strcase p0) "A")
- (setq p1 (getpoint "\nSpecify first extension line origin :")
- p2 (getpoint p1 "\nSpecify second extension line origin :")
- ang (* 180 (/ (angle p1 p2) pi))
- )
- )
- )
- (princ "\nSpecify dimension line location :")
- (command "_.dim1" "rotated" ang p1 p2 pause "")
- )
- (progn
- (setq p1 (getpoint p0 "\nSpecify second extension line origin :"))
- (princ "\nSpecify dimension line location :")
- (command "dimlinear" p0 p1 pause)
- )
- )
- (if (not (equal entst (entlast)))
- (progn
- (replace_ch "dim" 256 "bylayer" (entlast))
- (entmod (subst
- (cons 51 0)
- (assoc 51 (entget (entlast)))
- (entget (entlast))
- )
- )
- (setq dimtxt (cdr (assoc 42 (entget (entlast)))))
- (princ (strcat "\nDimension text = " (rtos dimtxt)))
- )
- )
- (ai_undo_pop)
- (setvar "cmdecho" 1)
- (princ)
- )
- [/FONT]
;|这是我用的尺寸标注的lisp程序,因为其中有我自己编写的函数,所以在你的机子上可能无法运行,
只是给你一个参考,(mlay "dim" 3)是图层创建函数,(matrix_b ent)是块转换阵列函数。
在这个程序中,将标注命令简化,但也有许多autocad命令中的选项没有加入,你可以加入它们,
靠你自己的聪明才智了。有什么问题再联系了
|;
请下载tem.lsp |