为了说明我的建议,请找一个带有注释的示例:
- (if (setq ssetPLine (ssget "_:S:E" '((0 . "LWPOLYLINE")))) ;ask user to select a polyline
- (progn
- (setq listPLine (entget (ssname ssetPLine 0)) ;retrive entity's list
- listCorners '())
- (while (setq listPLine (member (assoc 10 listPLine) listPLine)) ;cycle until all vertexes (corners) were found
- (setq listCorners (cons (cdar listPLine) ;and retain them in a list
- listCorners)
- listPLine (cdr listPLine)) ;skip first entry to allow locating next vertex
- )
- (print (inters (nth 0 listCorners) (nth 2 listCorners) ;get intersection of diagonals
- (nth 1 listCorners) (nth 3 listCorners)))
- )
- )
请注意,以上仅适用于矩形;稍后您需要添加SSGET筛选器(请检查Tharwat的代码)或选择后验证。 |