找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 473|回复: 0

[转贴]:AutoCAD自动标注的尺寸,以文字的形式重新标注

[复制链接]
发表于 2004-7-18 15:09:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我只是看见了这个程序决得不错在这里传贴,我也不懂,大家不要问我哈:)
(defun c:dimtotxt(/ ss ee leng n scale x y l text numb class al pre first second post) ;本程序用于将AutoCAD自动标注的尺寸,以文字的形式重新标注



(prompt "请选择要修改的实体")

(setq ss (ssget ) )

(setq leng (sslength ss) n 0 str "")

(setq scale (getvar "dimlfac") numb 0)

(repeat leng

(setq ee (ssname ss n))

(setq al (entget ee))

(setq name (cdr (assoc 0 al)))

(setq class (cdr (assoc 70 al)))

(setq pre "" post "")



(if (and (= "DIMENSION" name) (= (cdr (assoc 1 al)) ""))

(progn

(setq lx (cdr (assoc 70 al)))

(if (> lx 128)(setq lx (- lx 160))(setq lx (- lx 32)))

(if (= lx 0)(cc1))

(if (= lx 1)(cc2))

(if (= lx 2)(progn (setq post "%%d" )(cc3)))

(if (= lx 3)(progn (setq pre "%%c" )(cc4)))

(if (= lx 4)(progn (setq pre "R" ) (cc4)))

(if (= lx 6)(cc5))

(if (= lx 70)(cc6))



(setq text (rtos (* jbcc scale) 2 4) text (strcat pre text) text (strcat text post))



(setq al

(subst (cons 1 text) (assoc 1 al) al)

)



(entmod al)

(setq numb (1+ numb))

(princ "\n\n你修改的是对象是第几个:")

(princ numb)

(princ "\n现在标注为:")

(princ text)

) ;endprogn

) ;endif





(setq n (1+ n))





) ;endrep



(princ "\n\nSUMMARY:\n本程序将所有的自动标注转换成文本标注\n你所用的标注线性比例为:")

(princ scale);

(princ "\n总共修改个数")

(princ numb)

(princ "\n\n")

(princ)

(princ "如有问题,请与huihl@netease.com联系\n")



(command "line" '(0,0) "") ;此语句是为了回退(undo)的需要而编写,即一次只能回退一条操作。

) ;endfun







;;;以下函数得于司马奇

;;;==================================================

;;;==================基本尺寸查询函数==================

;;;======================BEGIN========================



;;;水平、垂直类型标注基本尺寸计算

(defun cc1(/ jj x1 x2)

(setq jj (cdr (assoc 50 al))

x1 (assoc 13 al)

x2 (assoc 14 al)

)

(if (= jj 0)

(setq jbcc (abs (- (nth 1 x1) (nth 1 x2))))

(setq jbcc (abs (- (nth 2 x1) (nth 2 x2))))

)



)



;;;倾斜类型标注基本尺寸计算

(defun cc2(/ x1 x2)

(setq x1 (assoc 13 al)

x2 (assoc 14 al)

)

(setq jbcc (sqrt (+ (* (- (nth 1 x1) (nth 1 x2)) (- (nth 1 x1) (nth 1 x2)))

(* (- (nth 2 x1) (nth 2 x2)) (- (nth 2 x1) (nth 2 x2)))

)))

)





;;;角度类型标注基本尺寸计算

(defun cc3(/ x1 x2 x3 x4 x5 ang1 ang2)

(setq x1 (assoc 13 al)

x2 (assoc 14 al)

x3 (assoc 10 al)

x4 (assoc 15 al)

x5 (assoc 11 al)

)

(setq ang1 (angle (list (nth 1 x1) (nth 2 x1))

(list (nth 1 x2) (nth 2 x2)))

ang2 (angle (list (nth 1 x3) (nth 2 x3))

(list (nth 1 x4) (nth 2 x4)))

)

(setq jbcc (rtd (abs (- ang1 ang2))))

)





;;;直径、半径类型标注基本尺寸计算

(defun cc4(/ x1 x2)

(setq x1 (assoc 10 al)

x2 (assoc 15 al)

)

(setq jbcc (sqrt (+ (* (- (nth 1 x1) (nth 1 x2)) (- (nth 1 x1) (nth 1 x2)))

(* (- (nth 2 x1) (nth 2 x2)) (- (nth 2 x1) (nth 2 x2)))

)))

)





;;;Y向坐标类型标注基本尺寸计算

(defun cc5(/ x1 x2)

(setq x1 (assoc 13 al)

x2 (assoc 10 al)

)

(setq jbcc (abs (- (nth 2 x1) (nth 2 x2))))

)





;;;X向坐标类型标注基本尺寸计算

(defun cc6(/ x1 x2)

(setq x1 (assoc 13 al)

x2 (assoc 10 al)

)

(setq jbcc (abs (- (nth 1 x1) (nth 1 x2))))

)



;;;弧度转换成角度函数

(defun rtd(ang)

(setq ang (/ (* ang 180) pi))

)

;;;==================================================

;;;==================基本尺寸查询函数===================

;;;======================THE END=======================
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-27 06:56 , Processed in 0.175701 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表