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

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 503



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.      (progn
  7.        (xdrx_begin)
  8.        (setq mp (xdrx_hatch->mpolygon e)
  9.              mp (entlast)
  10.        )
  11.        (if (and (setq closestLoop
  12.                        (xdrx_getpropertyvalue mp "ClosestLoopTo" p)
  13.                 )
  14.                 (setq childLoops
  15.                        (xdrx_getpropertyvalue
  16.                          mp
  17.                          "childloops"
  18.                          closestloop
  19.                        )
  20.                 )
  21.            )
  22.          (progn
  23.            (setq loopdata (xdrx_getpropertyvalue mp "MPolygonLoopAt" closestloop))
  24.            (xdrx_polyline_make loopdata)
  25.            (xdrx_setpropertyvalue (entlast) "constantwidth" 20.0 "color" 6)
  26.            (setq i -1)
  27.            (mapcar '(lambda (x)
  28.                       (setq loopdata (xdrx_getpropertyvalue
  29.                                        mp
  30.                                        "MPolygonLoopAt"
  31.                                        x
  32.                                      )
  33.                       )
  34.                       (xdrx_polyline_make loopdata)
  35.                       (xdrx_setpropertyvalue
  36.                         (entlast)
  37.                         "constantwidth"
  38.                         20.0
  39.                         "color"
  40.                         2
  41.                       )
  42.                     )
  43.                    childloops
  44.            )
  45.          )
  46.        )
  47.        (xdrx_entity_delete mp)
  48.        (xdrx_pickset_redraw e t)
  49.        (xdrx_end)
  50.      )
  51.    )
  52.    (princ)
  53. )

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

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.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net