Merge two color blocks (HATCH)
论坛中写的代码主要是为了演示将要介绍的主要函数的使用方法,可能有更好或更直接的实现方式。
以下代码主要介绍AcGe几何库函数,并使用MPOLYGON对象对HATCH实体进行UNION。
(efun c:XDTB-HatchUnion (/ e1 e2)
;| Use the AcGe geometry library to determine whether it intersects|;
(defun _hasInterPnts (e1 e2 / g1 g2 intv ret)
(setq ret
(and (setq g1 (xdrx-getpropertyvalue e1 "rootloopat" 0))
(setq g2 (xdrx-getpropertyvalue e2 "rootloopat" 0))
(setq intv (xdge::getpropertyvalue g1 "getinterval" g2))
)
)
(xdrx-object-release g1 g2 intv)
ret
)
(if (and
(setq e1 (car (xdrx-entsel "\nSelect main color block<Exit>:" '((0 . "HATCH")))))
(xdrx-pickset-redraw e1 3)
(setq e2 (car (xdrx-entsel "\nSelect the color blocks to be merged<Exit>:" '((0 . "HATCH")))))
(not (eq e1 e2))
)
(progn
(xdrx-begin)
(if (_hasInterPnts e1 e2)
(progn
(xdrx-hatch->mpolygon e1 t)
(xdrx-hatch->mpolygon e2 t)
(xdrx-mpolygon-union e1 e2)
(xdrx-mpolygon->hatch e1)
(xdrx-prompt "\nTwo color blocks were successfully merged.")
)
)
(xdrx-end)
)
)
(princ)
)
N版,猛男 !!
页:
[1]