请看下这段cad中的lsp代码为什么用不了?
这是自动提取cad文字的坐标和内容的lsp程序代码,然而像其他lsp程序一样操作后却运行不了(defunc:plwbsc()(princ"\n选择所需输出的文本TEXT:...
这是自动提取cad文字的坐标和内容的lsp程序代码,然而像其他lsp程序一样操作后却运行不了
(defun c:plwbsc()
(princ "\n选择所需输出的文本TEXT:")
(setq ss (ssget ));;选取坐标点
(setq n (sslength ss ));计算坐标点数量
(setq ff (open (getfiled "文件保存为" "f:/" "xls" 1) "w"));保存路径
(setq i 0)
(repeat n
(setq spt (ssname ss i ))
(setq ept (entget spt))
(if (= (cdr (assoc 0 ept)) "TEXT")
(progn
(setq lxyz (cdr (assoc 10 ept)))
(setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符
(setq sy (rtos (nth 0 lxyz)))
(setq sz (cdr (assoc 1 ept)))
(setq i1 (+ i 1));计算点序号
(setq sn (rtos i1 2 0));将序号实数转换成字符
(setq sxyz (strcat sn",," sy "," sx "," sz))
(write-line sxyz ff)
)
)
(setq i (+ i 1))
);repeat
)
(prompt "* << 命令:plwbsc >> *输出格式(点号,, Y,X,Z)**")
(prin1) 展开
(defun c:plwbsc()
(princ "\n选择所需输出的文本TEXT:")
(setq ss (ssget ));;选取坐标点
(setq n (sslength ss ));计算坐标点数量
(setq ff (open (getfiled "文件保存为" "f:/" "xls" 1) "w"));保存路径
(setq i 0)
(repeat n
(setq spt (ssname ss i ))
(setq ept (entget spt))
(if (= (cdr (assoc 0 ept)) "TEXT")
(progn
(setq lxyz (cdr (assoc 10 ept)))
(setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符
(setq sy (rtos (nth 0 lxyz)))
(setq sz (cdr (assoc 1 ept)))
(setq i1 (+ i 1));计算点序号
(setq sn (rtos i1 2 0));将序号实数转换成字符
(setq sxyz (strcat sn",," sy "," sx "," sz))
(write-line sxyz ff)
)
)
(setq i (+ i 1))
);repeat
)
(prompt "* << 命令:plwbsc >> *输出格式(点号,, Y,X,Z)**")
(prin1) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询