### Author Topic: [Topology-Hatch]Topological relationships of HATCH Boundaries(2) (LOOP)  (Read 862 times)

0 Members and 1 Guest are viewing this topic.

• Bull Frog
• Posts: 424
##### [Topology-Hatch]Topological relationships of HATCH Boundaries(2) (LOOP)
« on: November 17, 2023, 10:35:43 AM »

The following code demonstrates the process of using the XDRX API to obtain the boundary LOOP topological relationship of the filled entity.

1. Pick up and HATCH
2. Pick a test point near a boundary
3. The boundary entity is displayed in magenta, and all LOOPs inside the boundary are displayed in yellow.

Code - Auto/Visual Lisp: [Select]
1. (defun c:tt ()
2.    (if (and (setq e (xdrx_entsel "\nPick a HATCH<exit>:" '((0 . "HATCH"))))
3.             (xdrx_pickset_redraw e)
4.             (setq p (getpoint "\nClick a little near the HATCH Ring <Exit>:"))
5.        )
6.        (xdrx_begin)
7.        (setq mp (xdrx_hatch->mpolygon e)
8.              mp (entlast)
9.        )
10.        (if (and (setq closestLoop
11.                        (xdrx_getpropertyvalue mp "ClosestLoopTo" p)
12.                 )
13.                 (setq childLoops
14.                        (xdrx_getpropertyvalue
15.                          mp
16.                          "childloops"
17.                          closestloop
18.                        )
19.                 )
20.            )
21.            (setq loopdata (xdrx_getpropertyvalue mp "MPolygonLoopAt" closestloop))
22.            (xdrx_polyline_make loopdata)
23.            (xdrx_setpropertyvalue (entlast) "constantwidth" 20.0 "color" 6)
24.            (setq i -1)
25.            (mapcar '(lambda (x)
26.                       (setq loopdata (xdrx_getpropertyvalue
27.                                        mp
28.                                        "MPolygonLoopAt"
29.                                        x
30.                                      )
31.                       )
32.                       (xdrx_polyline_make loopdata)
33.                       (xdrx_setpropertyvalue
34.                         (entlast)
35.                         "constantwidth"
36.                         20.0
37.                         "color"
38.                         2
39.                       )
40.                     )
41.                    childloops
42.            )
43.          )
44.        )
45.        (xdrx_entity_delete mp)
46.        (xdrx_pickset_redraw e t)
47.        (xdrx_end)
48.      )
49.    )
50.    (princ)
51. )

=============

The above LISP code uses the XDRX-API, which can be downloaded from https://github.com/xdcad/XDrx-API

The XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.
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