必须是VBA吗?它可以在LISP中轻松完成。
但我不认为VBA有Break方法,但(希望)我会被证明是错误的。
如果LISP是一个选项,您可以尝试这样的东西(但需要错误检查、测试等)
(defun c:breakatPt()
(setq pline1 (car (entsel "\nPick Polyline:"))
ssPoints (ssget '((0 . "POINT")))
count 0
PtList (list)
);setq
;get list of points
(repeat (sslength ssPoints)
(setq PtList (append PtList (list (cdr (assoc 10 (entget (ssname sspoints count))))))
count (+ count 1)
)
);repeat
(setq count 0
DistList (list)
);setq
;; sort the points so we won't try to break the NEW pline that is created after a successful break
(repeat (length PtList)
(setq DistList (append DistList (list (vlax-curve-GetDistAtPoint Pline1 (vlax-curve-getClosestPointTo Pline1 (nth count PtList))))))
(setq count (+ 1 count))
);repeat
(setq DistListSortI (vl-sort-i DistList '>)
count 0
);setq
(repeat (sslength sspoints)
(setq breakPt (nth (nth count DistListSortI ) PtList))
(command "break" pline1 breakpt "@")
(setq count (+ 1 count))
);repeat
(prin1)
)