本帖最后由 自贡黄明儒 于 2013-4-26 16:53 编辑
1 先判断线的位置,分成两组
2 然后依次从两组中取线,并判断那一个点离虚交点近,然后倒角
A 分组
- ;;1 对象分组,返回组列表
- (defun ss:group (ss / ANG ANG1 ANG2 GETENDPOINT GROUP1 GROUP2 OBJ PARAM STARTPOINT)
- (setq obj (ssname ss 0))
- (SsDel obj SS)
- (setq StartPoint (vlax-curve-getStartPoint obj))
- (setq getEndPoint (vlax-curve-getEndPoint obj))
- (setq param (vlax-curve-getStartParam obj))
- ;;起点切线方向的角度值
- (setq ang (angle StartPoint
- (mapcar '+ StartPoint (vlax-curve-getFirstDeriv obj param))
- )
- )
- (setq ang1 (rem ang (/ pi 2)))
- (setq group1 (cons obj group1))
- (repeat (sslength ss)
- (setq obj (ssname ss 0))
- (SsDel obj SS)
- (setq StartPoint (vlax-curve-getStartPoint obj))
- (setq getEndPoint (vlax-curve-getEndPoint obj))
- (setq param (vlax-curve-getStartParam obj))
- ;;起点切线方向的角度值
- (setq ang (angle StartPoint
- (mapcar '+ StartPoint (vlax-curve-getFirstDeriv obj param))
- )
- )
- (setq ang2 (rem ang (/ pi 2)))
- (if (equal ang1 ang2 0.1)
- (setq group1 (cons obj group1))
- (setq group2 (cons obj group2))
- )
- )
- (list group1 group2)
- )
B 组排序- ;;2 排序
- (defun sortObjects (lst / LST1 MINPT N OBJ)
- ;;2.1 获取对象的外边框
- (defun HH:MinMaxPt (ent / MinPt MaxPt)
- (vla-GetBoundingBox
- (vlax-Ename->vla-Object ent)
- 'MinPt
- 'MaxPt
- )
- (mapcar 'vlax-safearray->list (list MinPt MaxPt))
- )
- ;;2.2 点表排序
- (defun Sort_pList (PLIST / p1 p2)
- (vl-sort plist
- '(lambda (p1 p2)
- (cond ((< (car (car p1)) (car (car p2))) T)
- ((and (= (car (car p1)) (car (car p2)))
- (< (cadr (car p1)) (cadr (car p2)))
- )
- T
- )
- (T nil)
- )
- )
- )
- )
- ;;2.3 列表排序
- (repeat (setq n (length lst))
- (setq obj (nth (setq n (1- n)) lst))
- (setq MinPt (car (HH:MinMaxPt obj)))
- (setq obj (list MinPt obj))
- (setq lst1 (cons obj lst1))
- )
- (Sort_pList lst1)
- )
C 第一组的第一根线与第二组的第一根线和最后一根线比较,决定第二组是否需要倒序
D 两线倒角时,是以起点还是终点处倒角
|