请教:论坛上找的调整标注基本尺寸单位小数位数的程序,为何要选择两次?
请教:论坛上找的调整标注基本尺寸单位小数位数的程序,为何要选择两次?使用时命令行提示如下:
命令: tt
请输入精度<保留小数点的位数>0
选择对象: 指定对角点: 找到 4 个
选择对象:
选择对象:
nil
希望达到效果:
1. 先选择标注对象,再输入命令“tt”时不再提示选择对象;
2. 先输入命令“tt”再先择对象时只需回车一次且命令行无“nil”提示
肯请大佬帮助
;;代码如下:
(defun c:tt (/ ss n cnt# enlst)
(vl-load-com)
(setq jidulst (list 'acDimPrecisionZero
'acDimPrecisionOne
'acDimPrecisionTwo
'acDimPrecisionThree
'acDimPrecisionFour
'acDimPrecisionFive
'acDimPrecisionSix
'acDimPrecisionSeven
'acDimPrecisionEight
))
(initget 5 "0 1 2 3 4 5 6 7 8")
(setq int# (getint "\n请输入精度<保留小数点的位数>"))
(while (setq ss (ssget '((0 . "DIMENSION"))))
(setq n (sslengthss )
cnt# n
)
(repeat n
(setq ename^ (ssname ss (setq cnt# (1- cnt#))))
(setq enameobj(vlax-ename->vla-object ename^ ))
(vlax-put-property enameobj 'PrimaryUnitsPrecision (eval (nth int# jidulst))))
)
)
或者这样吧
(defun c:tt (/ cnt# ename^ enameobj enlst int# jidulst n ss)
(vl-load-com)
(setq ss (cadr (ssgetfirst)))
(setq jidulst (list 'acDimPrecisionZero
'acDimPrecisionOne
'acDimPrecisionTwo
'acDimPrecisionThree
'acDimPrecisionFour
'acDimPrecisionFive
'acDimPrecisionSix
'acDimPrecisionSeven
'acDimPrecisionEight
))
(initget 5 "0 1 2 3 4 5 6 7 8")
(setq int# (getint "\n请输入精度<保留小数点的位数>"))
(if(and
(or ss (setq ss (ssget '((0 . "DIMENSION")))))
(setq i -1)
)
(progn
(while(setq s1 (ssname ss (setq i (1+ i))))
(setq enameobj(Vlax-Ename->Vla-Object s1))
(vlax-put-property enameobj 'PrimaryUnitsPrecision (eval (nth int# jidulst)))
)
)
)
(princ)
) (defun c:tt (/ cnt# ename^ enameobj enlst int# jidulst n ss)
(vl-load-com)
(setq ss (cadr (ssgetfirst)))
(setq jidulst (list 'acDimPrecisionZero
'acDimPrecisionOne
'acDimPrecisionTwo
'acDimPrecisionThree
'acDimPrecisionFour
'acDimPrecisionFive
'acDimPrecisionSix
'acDimPrecisionSeven
'acDimPrecisionEight
))
(initget 5 "0 1 2 3 4 5 6 7 8")
(setq int# (getint "\n请输入精度<保留小数点的位数>"))
(if (and
(or ss (setq ss (ssget '((0 . "DIMENSION")))))
(setq n (sslengthss )
cnt# n
)
)
(progn
(repeat n
(setq ename^ (ssname ss (setq cnt# (1- cnt#))))
(setq enameobj(vlax-ename->vla-object ename^ ))
(vlax-put-property enameobj 'PrimaryUnitsPrecision (eval (nth int# jidulst))))
)
)
(princ)
) xj6019 发表于 2024-6-9 17:04
或者这样吧
(defun c:tt (/ cnt# ename^ enameobj enlst int# jidulst n ss)
(vl-load-com)
感谢大佬,两个都可以
大神可以再把精度改成默认为"0"吗
这个意思?直接回车确定,默认为0?
(defun c:tt (/ cnt# ename^ enameobj enlst int# jidulst n ss)
(vl-load-com)
(setq ss (cadr (ssgetfirst)))
(setq jidulst (list 'acDimPrecisionZero
'acDimPrecisionOne
'acDimPrecisionTwo
'acDimPrecisionThree
'acDimPrecisionFour
'acDimPrecisionFive
'acDimPrecisionSix
'acDimPrecisionSeven
'acDimPrecisionEight
))
(initget"0 1 2 3 4 5 6 7 8")
(setq int# (getint "\n请输入精度<保留小数点的位数>"))
(if (not int#)
(setq int# 0)
int#
)
(if (and
(or ss (setq ss (ssget '((0 . "DIMENSION")))))
(setq n (sslengthss )
cnt# n
)
)
(progn
(repeat n
(setq ename^ (ssname ss (setq cnt# (1- cnt#))))
(setq enameobj(vlax-ename->vla-object ename^ ))
(vlax-put-property enameobj 'PrimaryUnitsPrecision (eval (nth int# jidulst))))
)
)
(princ)
) xj6019 发表于 2024-6-9 21:48
这个意思?直接回车确定,默认为0?
(defun c:tt (/ cnt# ename^ enameobj enlst int# jidulst n ss)
是这效果,再次感谢大佬 xj6019 发表于 2024-6-9 21:48
这个意思?直接回车确定,默认为0?
(defun c:tt (/ cnt# ename^ enameobj enlst int# jidulst n ss)
挺好用的,感谢分享
页:
[1]