一种解决方案是简单地添加选定多段线的最长边。
代码仅检查多段线是否闭合,是否有4条直线段。
- (defun KGA_Conv_Pickset_To_EnameList (ss / i ret)
- (if ss
- (repeat (setq i (sslength ss))
- (setq ret (cons (ssname ss (setq i (1- i))) ret))
- )
- )
- )
- (defun CableTrayLength_MaxSide (enm / ptLst)
- (setq ptLst
- (vl-remove
- nil
- (mapcar
- '(lambda (sub) (if (= 10 (car sub)) (cdr sub)))
- (entget enm)
- )
- )
- )
- (apply
- 'max
- (mapcar
- 'distance
- ptLst
- (cons (last ptLst) ptLst)
- )
- )
- )
- (defun c:CableTrayLength ( / res ss)
- (if
- (setq ss
- (ssget
- '(
- (0 . "LWPOLYLINE")
- (90 . 4)
- (-4 . "&=") (70 . 1)
- (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>")
- )
- )
- )
- (progn
- (setq res
- (apply '+ (mapcar 'CableTrayLength_MaxSide (KGA_Conv_Pickset_To_EnameList ss)))
- )
- (princ
- (strcat
- "\nTotal length of longest sides is: "
- (rtos res)
- )
- )
- )
- )
- (princ)
- )
|