Author Topic: [XDrX-PlugIn(6)] Intersect two color blocks (HATCH,REGIO,MPOLYGON)  (Read 724 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Bull Frog
  • Posts: 424
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 Intersect the HATCH,MPOLYGON,REGION,,Closed Curves(circle,ellipse,*polyline,spline...) entities.(any combination)

Code - Auto/Visual Lisp: [Select]
  1. ;|Can be between HATCH, REGION, MPOLYGON (any combination)|;
  2. (defun c:XDTB-IntSect (/ e1 e2)
  3.   ;| Use the AcGe geometry library to determine whether it intersects|;
  4.   (defun _hasInterPnts (e1 e2 / g1 g2 intv ret)
  5.     (setq ret
  6.            (and (setq g1 (xdrx-getpropertyvalue e1 "rootloopat" 0))
  7.                 (setq g2 (xdrx-getpropertyvalue e2 "rootloopat" 0))
  8.                 (setq intv (xdge::getpropertyvalue g1 "getinterval" g2))
  9.            )
  10.     )
  11.     (xdrx-object-release g1 g2 intv)
  12.     ret
  13.   )
  14.   (if (and
  15.         (setq e1 (car (xdrx-entsel "\nSelect main color block<Exit>:"'((0 . "HATCH,REGION,MPOLYGON")))))
  16.         (xdrx-pickset-redraw e1 3)
  17.         (setq e2 (car (xdrx-entsel "\nSelect the color blocks to be InterSect<Exit>:" '((0 . "HATCH,REGION,MPOLYGON")))))
  18.         (not (eq e1 e2))
  19.       )
  20.     (progn
  21.       (xdrx-begin)
  22.       (if (_hasInterPnts e1 e2)
  23.         (progn
  24.           (xdrx-get-intersect e1 e2)
  25.  
  26.           (xdrx-prompt "\nTwo color blocks were successfully InterSect.")
  27.         )
  28.       )
  29.       (xdrx-end)
  30.     )
  31.   )
  32.   (princ)
  33. )
  34.  
« Last Edit: November 26, 2023, 05:39:06 PM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net