修改,尺寸:比例因子,报错。请教如何处理?
(defun c:DS()(setqnDS (getvar "DIMSCALE"))
(setqstrDS (ljx-re-str nDS))
(setq stxt (getstring(strcat "\输入 DIMSCALE 的新值 <" strDS ">::<右键点取图框>")))
(if (= stxt "")
(progn
(vl-load-com)
(setq obj (vlax-ename->vla-object (car(entsel "点选对象:\n"))));;点选图框
(vla-GetBoundingBox obj 'p1 'p2);;获取图框的对角点
(setq p1 (vlax-safearray->list p1))
(setq p2 (vlax-safearray->list p2))
;;(command ".zoom" "w" p1 p2)
(setq bl (abs (vla-get-XScaleFactor obj)));;获取图框的比例
(command-s "DIMSCALE" bl)
)
(progn
(setq newDS (atof stxt))
(command-s "DIMSCALE" newDS)
)
)
(princ)
)
;;===========子函数================
(defun ljx-re-str (num / tmp fp dat)
(setq tmp (vl-filename-mktemp "mytmp.txt")
fp (open tmp "W")
)
(prin1 re fp)
(close fp)
(setq fp (open tmp "R"))
(setq dat (read-line fp))
(close fp)
(vl-file-delete tmp)
(if (= (read dat) (fix re));;;;为整数时
(setq dat (itoa (fix re)))
)
dat
)
;|报错如下:
调用(*push-error-using-command*)前无法从 *error* 调用(command)。
建议将(command)调用转换为(command-s)。
(command-s "DIMSCALE" bl)
修改成
(setvar "DIMSCALE" bl)
试一下 谢谢,这是个变量确实要用setvar
另外我那个转字符串也有点问题,改用简单的转换方法了
页:
[1]