- ;---去除多段线点集里面共线的点
- (defun re-pts(en / pts pts1 pts2 pts3)
- (setq pts(mapcar 'cdr(vl-remove-if-not '(lambda(x)(=(car x)10))(entget en))))
- (if(vlax-curve-isClosed(vlax-ename->vla-object en))
- (progn
- (setq pts2(append(cdr pts)(list(car pts))))
- (setq pts3(append(cdr pts2)(list(car pts2))))
- (vl-remove nil(mapcar '(lambda(x1 x2 x3)(if(equal 0(chaji x1 x2 x3)0.01)nil x2))pts pts2 pts3))
- )
- (progn
- (setq pts1(reverse(cdr(cdr(reverse pts)))))
- (setq pts2(cdr(reverse(cdr(reverse pts)))))
- (setq pts3(cdr(cdr pts)))
- (append(list(car pts))(vl-remove nil(mapcar '(lambda(x1 x2 x3)(if(equal 0(chaji x1 x2 x3)0.01)nil x2))pts1 pts2 pts3))(list(last pts)))
- )
- )
- )
- ;---向量叉积,等于0代表共线
- (defun chaji(p0 p1 p2)
- (-
- (*(-(car p1)(car p0))(-(cadr p2)(cadr p0)))
- (*(-(car p2)(car p0))(-(cadr p1)(cadr p0)))
- )
- )
核心子函数如上,不支持含有圆弧的多段线。
如果加上圆弧,可能复杂一点,,,暂时没思路
|