这里是一个开始,使用简单的测试分割一条线并沿其创建点,然后返回点的坐标。使用多if或COND将更整洁
- ; 1st step to find objects along a pline
- ; by Alan H
- (defun pointpline ( / ss x obj pt co-ordsxy)
- (if (not co-ords2xy) (load "pline co-ords"))
- (setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
- (co-ords2xy)
- (setq ss (ssget "F" co-ordsxy))
- (setq x (sslength ss))
- (repeat (sslength ss)
- (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1)))))
- (if (= "AcDbPoint" (vla-get-objectname obj))
- (setq pt (vlax-safearray->list (vlax-variant-value (vla-get-Coordinates obj))))
- )
- (princ pt)
- )
- )
- (pointpline)
你需要这个
- ; 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)
|