Author Topic: [XDrx-Topol]Topol Function (1) Introducing three intersect, union,subtract  (Read 733 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Bull Frog
  • Posts: 424
The API provides three powerful topology functions, intersection, union, and difference, which can implement intersection, union, and difference operations between any two entities such as Curves, Hatchs, Regions, and MPOLYGON.



The type of the resulting entity depends on the first entity, if the first one is a curve, the result is a curve, if the first one is a HATCH, the result is a HATCH....


Code - Auto/Visual Lisp: [Select]
  1. (xdrx-get-intersect e1 e2)
  2.  
  3. (xdrx-get-union e1 e2)
  4.  
  5. (xdrx-get-subtract e1 e2)
  6.  

Code - Auto/Visual Lisp: [Select]
  1. ;
  2. ;union
  3. (defun c:tt ()
  4.    (if (and (setq e1 (car
  5.                        (xdrx_entsel
  6.                          "\nPick Curve, Region, Hatch MPOLYGON<Exit>:"
  7.                          '((0 . "*line,arc,circle,ellipse,hatch,region,mpolygon"))
  8.                        )
  9.                      )
  10.             )
  11.             (setq e2 (car
  12.                        (xdrx_entsel
  13.                          "\nPick Curve, Region, Hatch, MPOLYGON<Exit>:"
  14.                          '((0 . "*line,arc,circle,ellipse,hatch,region,mpolygon"))
  15.                        )
  16.                      )
  17.             )
  18.        )
  19.      (progn (xdrx-get-union e1 e2))
  20.    )
  21.    (princ)
  22. )

Code - Auto/Visual Lisp: [Select]
  1. ;subtract
  2. (defun c:tt1 ()
  3.   (if (and (setq e1 (car
  4.                       (xdrx_entsel
  5.                          "\nPick Curve, Region, Hatch, MPOLYGON<Exit>:"
  6.                          '((0 . "*line,arc,circle,ellipse,hatch,region,mpolygon"))
  7.                        )
  8.                     )
  9.            )
  10.            (setq e2 (car
  11.                       (xdrx_entsel
  12.                          "\nPick Curve, Region, Hatch, MPOLYGON<Exit>:"
  13.                          '((0 . "*line,arc,circle,ellipse,hatch,region,mpolygon"))
  14.                        )
  15.                     )
  16.            )
  17.       )
  18.     (progn (xdrx-get-subtract e1 e2))
  19.   )
  20.   (princ)
  21. )


Code - Auto/Visual Lisp: [Select]
  1. ;Intersect
  2. (defun c:tt1 ()
  3.   (if (and (setq e1 (car
  4.                       (xdrx_entsel
  5.                          "\nPick Curve, Region, Hatch, MPOLYGON<Exit>:"
  6.                          '((0 . "*line,arc,circle,ellipse,hatch,region,mpolygon"))
  7.                        )
  8.                     )
  9.            )
  10.            (setq e2 (car
  11.                       (xdrx_entsel
  12.                          "\nPick Curve, Region, Hatch, MPOLYGON<Exit>:"
  13.                          '((0 . "*line,arc,circle,ellipse,hatch,region,mpolygon"))
  14.                        )
  15.                     )
  16.            )
  17.       )
  18.     (progn (xdrx-get-intersect e1 e2))
  19.   )
  20.   (princ)
  21. )
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