此修改标精度的程序,无法框选修改,求帮忙看看,谢谢
此修改标精度的程序,无法框选修改,求帮忙看看,谢谢,(defun C:CHJ ()
(VL-LOAD-COM)
;;; 在模型空间中选择标注对象
(setq dimObj (car (entsel "\n选择要修改精度的尺寸标注: ")))
(setq str_0 (cdr (assoc 0 (entget dimObj))))
(while (and (/= str_0 "LWPOLYLINE") (/= str_0 "DIMENSION"))
(setq dimObj (car (entsel "\n所选对象不是尺寸标注,请重新选择编辑对象: ")))
(setq str_0 (cdr (assoc 0 (entget dimObj))))
)
(setq dimObj (vlax-ename->vla-object dimObj))
(setq newTolerance (getint "\n输入标注新的公差精度: "))
(if (= newTolerance "")
(setq newTolerance 0)
(progn
(COND
((= newTolerance 0)(setq newTolerance acDimPrecisionZero))
((= newTolerance 1)(setq newTolerance acDimPrecisionOne))
((= newTolerance 2)(setq newTolerance acDimPrecisionTwo))
((= newTolerance 3)(setq newTolerance acDimPrecisionThree))
((= newTolerance 4)(setq newTolerance acDimPrecisionFour))
((= newTolerance 5)(setq newTolerance acDimPrecisionFive))
((= newTolerance 6)(setq newTolerance acDimPrecisionSix))
((= newTolerance 7)(setq newTolerance acDimPrecisionSeven))
((= newTolerance 8)(setq newTolerance acDimPrecisionEight))
(t(progn (princ "标注精度未改变")(VL-EXIT-WITH-VALUE 0)))
)
)
)
(vla-put-PrimaryUnitsPrecision dimObj newTolerance); 确定公差精度的改变
(vla-put-SuppressTrailingZeros dimObj :vlax-false)
;;; 读取并显示替代标注公差精度
(setq newTolerance (vla-get-PrimaryUnitsPrecision dimObj))
(princ "标注精度已经设定为: ")(princ newTolerance)(princ "位小数")
(princ)
)
xyp1964 发表于 2012-4-26 23:39
xyp1964大师的代码有用,感谢大师的无私奉献!
10楼的方法最好,语句简洁,测试结果很好,实现速度快。赞一个 10楼的方法最好,语句简洁,测试结果很好,实现速度快。赞一个 entsel本身就只能单选。如果要框选,请用
(setq ss (ssget "x" '((-4 . "<OR")(0 . "LWPOLYLINE)(0 . "DIMENSION")(-4 . "OR>"))))
(setq n 0)
(setq newTolerance (getint "\n输入标注新的公差精度: "));;;先设置后选择,不然每次都提示输入,那框选就没有意义了
(repeat (sslength ss)
(setq str_0 (ssname n ss))
(setq n (1+ n))
(setq dimObj (vlax-ename->vla-object dimObj))
;;;接你原来改精度的部分
) cabinsummer 发表于 2011-9-16 06:06 static/image/common/back.gif
entsel本身就只能单选。如果要框选,请用
(setq ss (ssget "x" '((-4 . "vla-object dimObj))
;;;接你原来 ...
非常感谢,图像是你女儿吗,很可爱呀 最近正好在想有这样的工具就好了。。 正好想写一个按颜色修改标注的程序,谢谢!
cabinsummer版主把你写的那加上去怎么不行。
(defun C:DJD ()
(VL-LOAD-COM)
(setq ss (ssget "x" '((-4 . "<OR")(0 . "LWPOLYLINE")(0 . "DIMENSION")(-4 . "OR>"))))
(setq n 0)
(setq newTolerance (getint "\n输入标注新的公差精度: "))
(repeat (sslength ss)
(setq str_0 (ssname n ss))
(setq n (1+ n))
(setq dimObj (vlax-ename->vla-object dimObj))
(progn
(COND
((= newTolerance 0)(setq newTolerance acDimPrecisionZero))
((= newTolerance 1)(setq newTolerance acDimPrecisionOne))
((= newTolerance 2)(setq newTolerance acDimPrecisionTwo))
((= newTolerance 3)(setq newTolerance acDimPrecisionThree))
((= newTolerance 4)(setq newTolerance acDimPrecisionFour))
((= newTolerance 5)(setq newTolerance acDimPrecisionFive))
((= newTolerance 6)(setq newTolerance acDimPrecisionSix))
((= newTolerance 7)(setq newTolerance acDimPrecisionSeven))
((= newTolerance 8)(setq newTolerance acDimPrecisionEight))
(t(progn (princ "标注精度未改变")(VL-EXIT-WITH-VALUE 0)))
)
)
)
(vla-put-PrimaryUnitsPrecision dimObj newTolerance); 确定公差精度的改变
(vla-put-SuppressTrailingZeros dimObj :vlax-false)
;;; 读取并显示替代标注公差精度
(setq newTolerance (vla-get-PrimaryUnitsPrecision dimObj))
(princ "标注精度已经设定为: ")(princ newTolerance)(princ "位小数")
(princ)
)
好帖,留名。。。。 本帖最后由 xyp1964 于 2012-4-26 23:40 编辑
(defun c:tt ()
(if (setq ss (ssget '((0 . "DIMENSION"))))
(progn
(setq nt (getint "\n输入标注新的公差精度: ")
n0
)
(repeat (sslength ss)
(setq s1 (ssname ss n)
n (1+ n)
ob (vlax-ename->vla-object s1)
nn (COND ((= nt 0) acDimPrecisionZero)
((= nt 1) acDimPrecisionOne)
((= nt 2) acDimPrecisionTwo)
((= nt 3) acDimPrecisionThree)
((= nt 4) acDimPrecisionFour)
((= nt 5) acDimPrecisionFive)
((= nt 6) acDimPrecisionSix)
((= nt 7) acDimPrecisionSeven)
((= nt 8) acDimPrecisionEight)
(t nil)
)
)
(if nn
(progn (vla-put-PrimaryUnitsPrecision ob nn)
(vla-put-SuppressTrailingZeros ob :vlax-false)
)
)
)
(if (< nn 9)
(progn (princ "标注精度已经设定为: ")
(princ nt)
(princ "位小数")
)
)
)
)
(princ)
) ;;直接用command的方法(defun c:tt ()
(if (and (setq nt (getint "\n输入标注新的公差精度: "))
(setq ss (ssget '((0 . "DIMENSION"))))
)
(progn
(setvar 'DIMDEC nt)
(command "dim" "upd" ss "" "e")
)
)
(princ)
)
页:
[1]
2