;;; |标注合并和断开程序
;;; |断开dimbreak,合并dimcombine
;;; |snsj 2004.4.8
;;; |标注断开
;;; |飞诗修订使其可在UCS下执行　2010-5-8
(defun c:DimBreak (/ ent ent1 getpt jpt pt1 pt2)
  (setq ent (car (entsel "\n选择要断开的标注<退出>:")))
  (or ent (fsxm-silenceexit))
  (setq getpt (getpoint "\n点取断开点:"))
  (or getpt (fsxm-silenceexit))
  (setvar "cmdecho" 0)
  (vl-cmdf "undo" "be")
  (vl-cmdf ".copy" ent "" '(0 0) "@")
  (setq ent1 (entlast))
  (setq pt1 (fsxm-getendxf ent 13))
  (if (= (vla-get-objectname (vlax-ename->vla-object ent))
	 "AcDbAlignedDimension"
      )
    (setq pt2 (fsxm-getendxf ent 14))
    (setq pt2 (polar pt1 (fsxm-getendxf ent 50) 1))
  )
  (setq jpt (fsxm-pt-prj (trans getpt 1 0) pt1 pt2))
  (fsxm-setendxf ent 13 jpt)
  (fsxm-setendxf ent1 14 jpt)
  (vl-cmdf "undo" "e")
  (princ)
)
;;; |标注合并
(defun c:DimCombine (/ ang1 ang2 ent ent1 maxpt	pt1 pt2	pt3 pt4	pt5 pt6
		     pt7 xl objnm)
  (defun objnm (ent)
    (vla-get-objectname (vlax-ename->vla-object ent))
  )
  (vla-StartUndoMark *doc*)
  (if (setq ent (car (entsel "\n选择要合并对标注<退出>:")))
    (progn
      (redraw ent 3)
      (setq ent1 (car (entsel "\n选择另一个标注对象<退出>:")))
      (redraw ent 4)
      (setq pt1	(fsxm-getendxf ent 13)
	    pt2	(fsxm-getendxf ent 14)
	    pt3	(fsxm-getendxf ent1 13)
	    pt4	(fsxm-getendxf ent1 14)
      )
      (if (= (objnm ent) "AcDbAlignedDimension")
	(setq ang1 (angle pt1 pt2))
	(setq ang1 (fsxm-getendxf ent 50))
      )
      (if (= (objnm ent1) "AcDbAlignedDimension")
	(setq ang2 (angle pt3 pt4))
	(setq ang2 (fsxm-getendxf ent1 50))
      )
      (if (or
	    (or
	      (equal ang2 ang1 1e-5)
	      (equal (+ pi ang2) ang1 1e-5)
	    )
	    (equal (- ang2 pi) ang1 1e-5)
	  )
	(progn
	  (setq	xl    (polar pt1 ang1 1)
		pt5   (fsxm-pt-prj pt2 pt1 xl)
		pt6   (fsxm-pt-prj pt3 pt1 xl)
		pt7   (fsxm-pt-prj pt4 pt1 xl)
		maxpt (vl-sort
			(list pt1 pt5 pt6 pt7)
			'(lambda (pt1 pt2 / v)
			   (setq v (- (car pt1) (car pt2)))
			   (if (equal v 0 1e-3)
			     (< (cadr pt1) (cadr pt2)) ;Y从小到大
			     (< v 0)	;X从小到大
			   )
			 )
		      )
	  )
	  (fsxm-setendxf ent 13 (car maxpt))
	  (fsxm-setendxf ent 14 (last maxpt))
	  (entdel ent1)
	)
	(princ "\n非平行的标注不能合并！")
      )
    )
  )
  (vla-EndUndoMark *doc*)
  (princ)
)




