Author Topic: [XDrX-PlugIn(23)] Rebuild Hatch Boundary (4 methods)  (Read 991 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 514
[XDrX-PlugIn(23)] Rebuild Hatch Boundary (4 methods)
« on: December 01, 2023, 09:18:24 PM »
the first method:

Convert Hatch to MPolygon, then convert MPolygon back to Hatch

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (setq ss (xdrx-ssget
  3.                  "\nSelect Hatch to Rebuild the Boundary <Exit>:"
  4.                  '((0 . "hatch"))
  5.                )
  6.       )
  7.     (progn
  8.       (xdrx-begin)
  9.       (setq nums (sslength ss))
  10.       (mapcar '(lambda (x)
  11.                  (setq mp (xdrx-hatch->mpolygon x)
  12.                        ha (xdrx-mpolygon->hatch mp)
  13.                  )
  14.                  (xdrx-entity-matchprop x ha)
  15.                  (setq ha  (xdrx-ss-getsub ha '((0 . "hatch")))
  16.                        ha1 (ssname ha 0)
  17.                  )
  18.                  (xdrx-object-swapid x ha1)
  19.                  (xdrx-entity-delete ha1)
  20.                  (xdrx-entity-setcolor
  21.                    (xdrx-getpropertyvalue x "assocobjids")
  22.                    7
  23.                  )
  24.                )
  25.               (xdrx-ss->ents ss)
  26.       )
  27.       (xdrx-prompt
  28.         "\nSuccessfully Created "
  29.         nums
  30.         " Hatch Boundary."
  31.       )
  32.       (xdrx-end)
  33.     )
  34.   )
  35.   (princ)
  36. )
« Last Edit: December 01, 2023, 10:47:29 PM by xdcad »
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

xdcad

  • Swamp Rat
  • Posts: 514
Re: [XDrX-PlugIn(23)] Rebuild Hatch Boundary
« Reply #1 on: December 01, 2023, 09:55:47 PM »
the second method:

1.make hatch
2. append loop to Hatch
3. The Loop is Assoc to Hatch

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (setq ss (xdrx-ssget
  3.                  "\nSelect Hatch to Rebuild the Boundary <Exit>:"
  4.                  '((0 . "hatch"))
  5.                )
  6.       )
  7.     (progn
  8.       (xdrx-begin)
  9.       (setq nums (sslength ss))
  10.       (mapcar '(lambda (x)
  11.                  (setq loops (xdrx-getpropertyvalue x "getloops"));;Get Hatch ALL Loops
  12.                  (setq ha (xdrx-hatch-make);;Make a Memory Hatch
  13.                        ha (xdrx-entity-make ha);;Create to Database
  14.                  )
  15.                  (mapcar
  16.                    '(lambda (loop)
  17.                       (setq e (xdrx-entity-make loop));;Create Loop Curve To Database
  18.                       (xdrx-setpropertyvalue ha "appendloop" (list 0 e));;Append Loop To Hatch
  19.                       (xdrx-entity-setcolor e 7)
  20.                     )
  21.                    loops
  22.                  )
  23.                  (xdrx-entity-matchprop x ha)
  24.                  (xdrx-object-swapid x ha);Exchange Objectid,ensure EntityName Not Change
  25.                  (xdrx-entity-delete ha)
  26.                  (xdrx-setpropertyvalue ha "removeloopat" 0)
  27.                )
  28.               (xdrx-ss->ents ss)
  29.       )
  30.       (xdrx-prompt
  31.         "\nSuccessfully Created "
  32.         nums
  33.         " Hatch Boundary."
  34.       )
  35.       (xdrx-end)
  36.     )
  37.   )
  38.   (princ)
  39. )
  40.  
« Last Edit: December 01, 2023, 10:17:38 PM by xdcad »
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

xdcad

  • Swamp Rat
  • Posts: 514
Re: [XDrX-PlugIn(23)] Rebuild Hatch Boundary
« Reply #2 on: December 01, 2023, 10:10:52 PM »
Third method:

1. Extract HATCH LOOP information,
2. Directly generate LOOP curves
3. In this way, the boundary and HATCH are not Assoc

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (setq ss (xdrx-ssget
  3.                  "\nSelect Hatch to Rebuild the Boundary <Exit>:"
  4.                  '((0 . "hatch"))
  5.                )
  6.       )
  7.     (progn
  8.       (xdrx-begin)
  9.       (setq nums (sslength ss))
  10.       (mapcar '(lambda (x)
  11.                  (setq loops (xdrx-getpropertyvalue x "getloops"));;Get Hatch ALL Loops(AcGe)
  12.                       (setq e (xdrx-entity-make loops));Create Loops urve To Database
  13.                       (xdrx-entity-setcolor e 7)
  14.                )
  15.               (xdrx-ss->ents ss)
  16.       )
  17.       (xdrx-prompt
  18.         "\nSuccessfully Created "
  19.         nums
  20.         " Hatch Boundary."
  21.       )
  22.       (xdrx-end)
  23.     )
  24.   )
  25.   (princ)
  26. )
  27.  
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

xdcad

  • Swamp Rat
  • Posts: 514
Re: [XDrX-PlugIn(23)] Rebuild Hatch Boundary
« Reply #3 on: December 01, 2023, 10:45:00 PM »
Method 4
1. Get all LOOPS of the filled entity
2. Use the function (xdrx-hatch-make loops) to directly generate it once
3.loop is assoc

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (setq ss (xdrx-ssget
  3.                  "\nSelect Hatch to Rebuild the Boundary <Exit>:"
  4.                  '((0 . "hatch"))
  5.                )
  6.       )
  7.     (progn
  8.       (xdrx-begin)
  9.       (setq nums (sslength ss))
  10.       (mapcar '(lambda (x)
  11.                  (if (and
  12.                        (setq loops (xdrx-getpropertyvalue x "getloops"))
  13.                        ;;Get Hatch ALL Loops(AcGe)
  14.                        (setq e (xdrx-entity-make loops))
  15.                        (setq ha (xdrx-hatch-make e))
  16.                      )
  17.                    (progn
  18.                      (setq ha (xdrx-ss-getsub ha '((0 . "hatch"))))
  19.                      (xdrx-entity-matchprop x ha)
  20.                      (xdrx-object-swapid x (ssname ha 0))
  21.                      (xdrx-entity-delete ha)
  22.                    )
  23.                  )
  24.                )
  25.               (xdrx-ss->ents ss)
  26.       )
  27.       (xdrx-prompt
  28.         "\nSuccessfully Created "
  29.         nums
  30.         " Hatch Boundary."
  31.       )
  32.       (xdrx-end)
  33.     )
  34.   )
  35.   (princ)
  36. )
  37.  
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

xdcad

  • Swamp Rat
  • Posts: 514
Re: [XDrX-PlugIn(23)] Rebuild Hatch Boundary
« Reply #4 on: December 01, 2023, 10:46:53 PM »
Method 5

1.root loop creation and filling
2. Get all internal LOOPs
3. Use xdrx-get-intersect to find the intersect of HATCH and internal boundaries.

................
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