访问代码wi中的实体
你好我不知道如何轻松访问使用编码窗口选择创建的选择集的第一个实体。
我想读出在编码窗口选择集中“抓取”的两个不同对象的第一个点的坐标。一条多段线,一条线。然后我想把直线从它的第一个点作为基点复制到多段线的第一个点。我想把它复制到多段线的所有其他点。
因此,了解如何访问(读取)物体的第二个、第三个等点更有趣。。。使用visual lisp。
以下代码首先使用线应复制到的对象的拾取和线基点的静态坐标,而不是读取坐标:
(vl-load-com)
(setq sel1 (ssget "_w" '(-2 -2) '(115 10)))
(setq e (car (entsel)))
(setq topoint (vlax-curve-getStartPoint e))
(command "_.COPY" sel1 "" "0,0" topoint) 有几种方法可以访问选择集中的项目-本教程介绍了几种方法的优缺点。 这是一个pline坐标系,它列出了顶点列表。你只需要一个entsel,然后检查它是一个pline还是一条line等等。我最近发布了一些东西,它可以满足你的大部分需求。将尝试查找。
; pline co-ords example
; By Alan H
(defun getcoords (ent)
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property
(vlax-ename->vla-object ent)
"Coordinates"
)
)
)
)
(defun co-ords2xy ()
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
)
; program starts here
(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
(co-ords2xy)
; look at varaible co-ordsxy which is a list of vertices
(princ co-ordsxy)
页:
[1]