好的,现在可以很容易地使用基于X或Y的点列表进行排序。我的第一篇文章是关于X和Y的排序,稍后会尝试发布一些东西,现在需要做一些工作。
- ; pline co-ords example
- ; By Alan H
- (defun getcoords (ent)
- (vlax-safearray->list
- (vlax-variant-value
- (vlax-get-property
- obj
- "Coordinates"
- )
- )
- )
- )
- ; 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
- (defun co-ords2xy ()
- (setq len (length co-ords))
- (if (= (vla-get-objectname obj) "AcDbLwpolyline")
- (setq numb (/ len 2)) ; even and odd check required
- (setq numb (/ len 2)))
- (setq I 0)
- (repeat numb
- (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
- ; odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
- (setq co-ordsxy (cons xy co-ordsxy))
- (setq I (+ I 2))
- )
- )
- ; program starts here
- (defun C:ahjoinX ( / co-ordsxy lst)
- (setq obj (vlax-ename->vla-object (car (entsel "\nplease pick pline"))))
- (setq co-ords (getcoords obj))
- (co-ords2xy)
- (setq lst (vl-sort co-ordsxy
- (function (lambda (e1 e2)
- (< (car e1) (car e2)))))
- )
- (command "_pline")
- (while (= (getvar "cmdactive") 1 )
- (repeat (setq x (length lst))
- (command (nth (setq x (- x 1)) lst))
- )
- (command "")
- )
- (princ)
- )
- (C:ahjoinx)
|