稍微修改以接受具有相同起点和终点的开放多段线。。。
- (defun c:Test (/ ss h)
- (vl-load-com)
- (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
- ((lambda (space)
- (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*))
- (if (or (vlax-curve-isClosed x)
- (equal (vlax-curve-getStartPoint x) (vlax-curve-getEndPoint x))
- )
- (progn
- (vla-put-layer
- (setq h (vla-AddHatch space acHatchPatternTypePredefined "SOLID" :vlax-true))
- (vla-get-layer x)
- )
- (vlax-invoke h 'AppendOuterLoop (list x))
- (vlax-invoke h 'Evaluate)
- )
- )
- )
- (vla-delete ss)
- )
- (if (or (eq acmodelspace
- (vla-get-activespace
- (cond (*AcadDoc*)
- ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
- )
- )
- )
- (eq :vlax-true (vla-get-mspace *AcadDoc*))
- )
- (vla-get-modelspace *AcadDoc*)
- (vla-get-paperspace *AcadDoc*)
- )
- )
- )
- (princ)
- )
|