Author Topic: Detect closed rectangle inside hatch lines by given point  (Read 1208 times)

0 Members and 1 Guest are viewing this topic.

kozmos

  • Newt
  • Posts: 114
Detect closed rectangle inside hatch lines by given point
« on: January 02, 2021, 08:54:06 PM »
Is there a simple way to get the internal closed rectangle (or other shape polyline) rounded by hatch line just though picking a point inside the hatch?
As per in the attached picture, how to get the RED rectangle just by picking a PURPLE point inside the hatch.
KozMos Inc.

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Detect closed rectangle inside hatch lines by given point
« Reply #1 on: January 04, 2021, 11:32:56 PM »
Not simple but explode hatch pick point, bpoly get co-ords of bpoly, then undo a couple of times till hatch is back, the bpoly co-ords are still in memory so can do a draw pline from them.

Code: [Select]
(defun AHpllst ( lst / x)
(command "_pline")
(while (= (getvar "cmdactive") 1 )
(repeat (setq x (length lst))
(command (nth (setq x (- x 1)) lst))
)
(command "C") ; use "" for open pline
)
)

a bit more
explode
do bpoly
(setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast))))
undo twice
« Last Edit: January 04, 2021, 11:39:42 PM by BIGAL »
A man who never made a mistake never made anything

kozmos

  • Newt
  • Posts: 114
Re: Detect closed rectangle inside hatch lines by given point
« Reply #2 on: January 06, 2021, 07:46:36 AM »
I already know it can be done by exploding hatch and bpoly. At the moment, I am doing that by isolating the hatch and it's boundary curve before call bpoly and it takes very long time. I want a more simple and reliable way to avoid using bpoly since there  might be other graphic objects in that internal region which may cause the bpoly returning a wrong boundary. 
KozMos Inc.

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Detect closed rectangle inside hatch lines by given point
« Reply #3 on: January 06, 2021, 07:28:24 PM »
Ok a cheats way pick hatch, pick pt, copy it a distance to right, explode, adjust pt X co-ord then bpoly, move bpoly (entlast) back to left known distance delete copy hatch. This should be fast. You can use Extmin extmax to work out a suitable distance for me maybe 500.

Is -Layiso not fast enough ?
A man who never made a mistake never made anything