Author Topic: [XDrX-PlugIn(7)] Subtract two color blocks (HATCH,REGION,MPOLYGON)  (Read 857 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 514

The code written in the forum is mainly to demonstrate the usage of the main functions to be introduced. There may be a better or direct way to implement it.

The following code mainly introduces the AcGe geometry library function and uses the MPOLYGON object to Subtract the HATCH,MPOLYGON,REGION entities.(any combination)


Code - Auto/Visual Lisp: [Select]
  1. (defun c:XDTB-Subtract (/ e1 e2)
  2.   ;| Use the AcGe geometry library to determine whether it intersects|;
  3.   (defun _hasInterPnts (e1 e2 / g1 g2 intv ret)
  4.     (setq ret
  5.            (and (setq g1 (xdrx-getpropertyvalue e1 "rootloopat" 0))
  6.                 (setq g2 (xdrx-getpropertyvalue e2 "rootloopat" 0))
  7.                 (setq intv (xdge::getpropertyvalue g1 "getinterval" g2))
  8.            )
  9.     )
  10.     (xdrx-object-release g1 g2 intv)
  11.     ret
  12.   )
  13.   (if (and
  14.         (setq e1 (car (xdrx-entsel "\nSelect main color block<Exit>:"'((0 . "HATCH,REGION,MPOLYGON")))))
  15.         (xdrx-pickset-redraw e1 3)
  16.         (setq e2 (car (xdrx-entsel "\nSelect the color blocks to be Subtract.<Exit>:" '((0 . "HATCH,REGION,MPOLYGON")))))
  17.         (not (eq e1 e2))
  18.       )
  19.     (progn
  20.       (xdrx-begin)
  21.       (if (_hasInterPnts e1 e2)
  22.         (progn
  23.           (xdrx-get-subtract e1 e2)
  24.  
  25.           (xdrx-prompt "\nTwo color blocks were successfully Subtract.")
  26.         )
  27.       )
  28.       (xdrx-end)
  29.     )
  30.   )
  31.   (princ)
  32. )
  33.  
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net