无论如何,以下代码最终就足够了:
(defun c:thirdline ( / s e ) ;routine to get the length of a line, divide it by 3 then print the result
(if (setq s (ssget "_+.:S:E" '((0 . "LINE"))))
(setq s1 (rtos (distance (cdr (assoc 10 (setq e (entget (ssname s 0))))) (cdr (assoc 11 e))) 2))
)
(setq s2 (atof s1))
(setq s3 (/ s2 3))
(princ s3)
(princ)
)
vlisp
(defun c:div3 (/ e)
(if (and (setq e (car (entsel "\nPick line..\n")))
(vlax-property-available-p (setq e (vlax-ename->vla-object e)) 'length)
)
(princ (rtos (/(vla-get-length e)3.0)2 3))
(princ "\noops.. ")
)
(princ)
)
(vl-load-com)
像往常一样快速简单
我们应该注意长度结果是3D的吗?
一些在2D中工作的人可能会在不学习代码的情况下使用任何lisp。
如果搞砸了,lisper会受到责备吗?
谢谢hanhphuc
如果用户没有选择一条线或一个没有长度属性的对象,那么他们会被搞砸 Martyn3200了解对象的“dxf代码”有一系列返回对象属性的代码。作为一条线的示例
0对象类型线
8层
10起点
11终点
0对象类型块
2区块名称
8层
10插入点
在VL下载Dumpit。lsp和加载它,选择你的行你会看到一个列表的各种信息,如'长度选择一个pline和'地区将返回只是使用上述代码。使用COND,您可以有一个程序根据对象类型返回大量信息,准备好使用“角度”如何。
页:
1
[2]