本帖最后由 hubeiwdlue 于 2024-2-24 18:27 编辑
我想缩放图形,同时修改标注样式中的全局比例(40组码)和测量单位比例因子。但是写的代码总是有问题,请教大家错在那里。
- (defun emod (ent code value)
- (if (= (type ent) 'ename) (setq ent (entget ent)))
- (setq b(cons code value))
- (if(setq a(assoc code ent))
- (entmod(subst b a ent))
- (entmod(append ent(list b))))
- )
- (defun c:tt()
- (princ "\n 选择缩放对象")
- (setq ss (ssget))
- (setq pt1 (getpoint "\n选择基点"))
- (setq sfbili (getreal "\n 输入缩放比例"))
- (vl-cmdf "_.SCALE" ss "" pt1 sfbili "")
- (setq dimstyles (vla-get-dimstyles (vla-get-activedocument (vlax-get-acad-object))))
- (vlax-for dim dimstyles
- (setq name (vla-get-name dim))
- (setq dent (entget (tblobjname "dimstyle" name)));;标注样式名为name的符号表条目
- (setq dim144 (getvar "DIMLFAC"));;标注样式比例因子
- (setq dim40 (getvar "DIMSCALE"));;标注样式全局比例
- ;(setvar "DIMLFAC" (/ dim144 sfbili))
- ;(setvar "DIMSCALE" (* dim40 sfbili))
- (emod dent 144 (/ dim144 sfbili))
- (emod dent 40 (* dim40 sfbili))
- )
- (princ)
- )
|