您存储了原始实体,一旦原始实体被破坏,您可以访问新实体(将是原始的和新的-使用entlast获取)。
下面是一个丑陋的例子:
-
- (defun c:bl2(/ pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 x1 x2 ss
- lk flag sca size ds os ptbrk ang
- e1 e2 e3 e4 SB_pickpoint SB_next SB_ent SB_proceed
- SB_next SB_distance SB_entlist SB_closest_point SB_closest_ent SB_newent
- )
- (setq sel1 nil)
- (setq pt1 (getpoint "\nSpecify first point for breakline: ")
- pt2 (getpoint pt1 "\nSpecify second point for breakline: ")
- BrkScale 1.0;temp scale to 1
- );setq
- (command "Pline" pt1 pt2 "")
- (setq SB_ent (entlast)
- e2 (entlast)
- SB_pickpoint T
- SB_next nil
- SB_entlist (list SB_ent)
- );setq
- (while
- (setvar "osmode" 512)
- (setq SB_pickpoint (getpoint (if SB_next
- "\nSpecify next breakpoint: "
- "\nSpecify breakpoint: "
- );if
- ))
- (setq SB_proceed T
- SB_next T
- SB_distance 1.0e+012
- );setq
- ;;; Find the closest element of all the sub-elements ;
- (foreach SB_nth SB_entlist
- (setq SB_obj (vlax-ename->vla-object SB_nth)
- SB_foundpoint (vlax-curve-getClosestPointTo SB_obj
- SB_pickpoint nil)
- );setq
- (if (< (setq SB_temp (distance SB_pickpoint SB_foundpoint)) SB_distance)
- (setq SB_distance SB_temp
- SB_closest_ent SB_nth
- SB_closest_point SB_foundpoint
- );setq
- );if
- );foreach
- (command "_break" SB_closest_ent SB_closest_point SB_closest_point)
- ;;; add the newly created element to the sub-elements ;
- (setq SB_newent (entlast))
- ;;; (setq sel1 (ssadd SB_newent e2))
- (if (not (member SB_newent SB_entlist))
- (setq SB_entlist (cons SB_newent SB_entlist))
- );if
- (command ".INSERT"
- "BRKLINE2"
- SB_closest_point
- BrkScale;scale
- ""
- pt1
- pt2 ;angle
- )
- (command ".EXPLODE" "LAST");explode block to pline
- (setq e3(entlast))
- ;;; (setq sel2 (ssadd sel1 e3))
- (setq
- pt4 (polar SB_closest_point (angle pt1 pt2) (* 1.5 BrkScale))
- pt4a (polar pt4 (*(angle pt1 pt2)(* 0.5 pi))(* 1.5 BrkScale))
- pt4b (polar pt4 (*(angle pt1 pt2)0.5 pi)(* 1.5 BrkScale))
- pt5 (polar SB_closest_point (-(angle Pt1 Pt2)(* 1.25 pi))(* 1.5 BrkScale))
- pt6 (polar SB_closest_point (+(angle Pt1 Pt2)(* 1.25 pi))(* 1.5 BrkScale))
- pt7 (polar SB_closest_point (-(angle Pt2 Pt1)(* 1.25 pi))(* 1.5 BrkScale))
- pt8 (polar SB_closest_point (+(angle Pt2 Pt1)(* 1.25 pi))(* 1.5 BrkScale))
- );setq
- (setvar "OSMODE" 0)
- (command "trim" e3 "" "fence" pt6 pt5 "" "")
- (command "trim" e3 "" "fence" pt7 pt8 "" "")
- ;;; (command "_.PEDIT" e3 "JOIN" e1 "" "")
- );while
- (princ)
- );defun
它将在两个拾取的点之间绘制一条线,然后在中点处打断并连接成多段线。 |