Jump to content

Get outer regions and region intersection question


lastknownuser

Recommended Posts

Wanted to ask what would be the best way to get all outer regions of selected lines. Image attached, want to select only the outer regions marked red. My idea was to loop through all created regions, determine the one with largest area, then check if that one intersects with other, if yes remove them from selection set. If any left do it again, if like in this example there are two separate, not connected areas. Is there any better, faster way to do that?

Also question about intersection, if I select two regions that are touching in for example 3 points, I get a list of length 24 (8 points), so I have double points. I plan to use those points also later for something, is it possible to avoid these doubles? Or I'll have to filter those
Here is the code I use to get intersection

(vlax-invoke (vlax-ename->vla-object (car (entsel))) 'IntersectWith (vlax-ename->vla-object (car (entsel))) acextendnone)


test2.png

Edited by lastknownuser
Link to comment
Share on other sites

Easy manual way 1st draw a single random closed pline shape around your objects, then do Bpoly, pick a point just inside the dummy outer pline, then delete the 2, yes two dummy plines you have your result. Use (entlast) and get pline vertice points. Set desired layer 1st. 

 

Ok so will leave it to you to do a lisp version. 

Edited by BIGAL
Link to comment
Share on other sites

37 minutes ago, BIGAL said:

Easy manual way 1st draw a single random closed pline shape around your objects, then do Bpoly, pick a point just inside the dummy outer pline, then delete the 2, yes two dummy plines you have your result. Use (entlast) and get pline vertice points. Set desired layer 1st. 

 

Ok so will leave it to you to do a lisp version. 


You described this right? https://www.lee-mac.com/outlineobjects.html
 

Maybe I should have said it, I'm using regions for a reason and want to avoid using command boundary, because it does not give good result for large areas especially if there are short lines. Its precision depends on zoom. Also using regions is much faster.

I'm just wondering if there is a better and faster way to determine outer regions than the one I described in first post.

Link to comment
Share on other sites

3 hours ago, lastknownuser said:

Also question about intersection, if I select two regions that are touching in for example 3 points, I get a list of length 24 (8 points), so I have double points. I plan to use those points also later for something, is it possible to avoid these doubles? Or I'll have to filter those
Here is the code I use to get intersection

(vlax-invoke (vlax-ename->vla-object (car (entsel))) 'IntersectWith (vlax-ename->vla-object (car (entsel))) acextendnone)

 


Okay I think I figured this out, result are points for each line of region that intersects, in my example I had 8 lines that intersect

Link to comment
Share on other sites

If you have CIV3D you have "shrinkwrap". If prepared to pay there is boundary software out there that does extreme complex shapes.

 

Back to Bpoly what is slow about it, post a sample dwg. Yes at around 445 objects starts to slow down a bit. Took a few seconds.

Edited by BIGAL
Link to comment
Share on other sites

No civil available unfortunately, even though I think AutoCAD map would be more suitable for my needs, not sure.
I need something very specific, and something I can change/adjust by the needs, so I'd rather do it myself, I know I can make it, I have the idea, just trying to figure out the best, most efficient way to do it.
I attached sample dwg of some made up area. Method you described makes more polylines than needed (photo attached), but what is the real problem for me are missing vertices (I drew red arrow where they are missing). At least they are missing for me on my AutoCAD.
And like in first post, I can have many areas like this separated (smaller or bigger), which complicates things, and I'd like to outline them all at once
 

TEST2.png

OUTER BOUNDARY TEST.dwg

Link to comment
Share on other sites

I think the answer is in that I made all internal linework on another layer and turned that layer off then did a JOIN a couple of trims and add a line and got a good Pline answer reflecting the red outer line work. Maybe 2-3 minutes work. Having internals on for automation would probably always give wrong answers.

 

image.png.08ca315f9178f7ac132f6964f178d9dd.png

Link to comment
Share on other sites

https://www.theswamp.org/index.php?topic=59615.0

 

Video_2024-06-13_140945.gif.28692ac41017fed586e86ef8af20e65c.gif

 

Search Outlines:

 

(defun c:xdtb_searchoutlines (/ ss)
  (xdrx-begin)
  (xd::doc:getdouble
    (xdrx-string-multilanguage "\n输入容差" "\nInput tolerance")
    "#xd-var-global-equalpoint-tol"
    (xdrx-getvar "equalpoint")
  )
  (xdrx-sysvar-push (list "equalpoint" #xd-var-global-equalpoint-tol))
  (and (setq ss	(xdrx-ssget
		  (xdrx-string-multilanguage
		    "\n选择生成regions的曲线<退出>:"
		    "\nSelect to generate Curves for regions <Exit>:"
		  )
		  '((0 . "*line,arc"))
		)
       )
       (setq ss (xdrx-geom-searchoutline ss))
       (xdrx-prompt
	 (xdrx-string-formatex
	   (xdrx-string-multilanguage
	     "\n生成了 %d 个regions."
	     "\nGenerated %d regions."
	   )
	   (sslength ss)
	 )
       )
  )
  (xdrx-sysvar-pop)
  (xdrx-end)
  (princ)
)

 

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

 

The above code uses XDrx API,

download link:

https://github.com/xdcad/XDrx-API-zip

https://sourceforge.net/projects/xdrx-api-zip/

Dual version link:

https://github.com/xdcad

  • Like 1
Link to comment
Share on other sites

https://www.theswamp.org/index.php?topic=59614.0

 

Video_2024-06-13_135603.gif.6a1c815747f7c4126670b10aa68f566a.gif

 

2: Search Regions:

 

(defun c:xdtb_searchregions (/ ss)
  (xdrx-begin)
  (xd::doc:getdouble
    (xdrx-string-multilanguage "\n输入容差" "\nInput tolerance")
    "#xd-var-global-equalpoint-tol"
    (xdrx-getvar "equalpoint")
  )
  (xdrx-sysvar-push (list "equalpoint" #xd-var-global-equalpoint-tol))
  (and (setq ss	(xdrx-ssget
		  (xdrx-string-multilanguage
		    "\n选择生成regions的曲线<退出>:"
		    "\nSelect to generate Curves for regions <Exit>:"
		  )
		  '((0 . "*line,arc"))
		)
       )
       (setq ss (xdrx-geom-searchregions ss))
       (xdrx-prompt
	 (xdrx-string-formatex
	   (xdrx-string-multilanguage
	     "\n生成了 %d 个regions."
	     "\nGenerated %d regions."
	   )
	   (sslength ss)
	 )
       )
  )
  (xdrx-sysvar-pop)
  (xdrx-end)
  (princ)
)

 

 

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

 

The above code uses XDrx API,

download link:

https://github.com/xdcad/XDrx-API-zip

https://sourceforge.net/projects/xdrx-api-zip/

Dual version link:

https://github.com/xdcad

 

 

Link to comment
Share on other sites

2 hours ago, XDSoft said:

https://www.theswamp.org/index.php?topic=59615.0

 

Video_2024-06-13_140945.gif.28692ac41017fed586e86ef8af20e65c.gif

 

Search Outlines:

 

(defun c:xdtb_searchoutlines (/ ss)
  (xdrx-begin)
  (xd::doc:getdouble
    (xdrx-string-multilanguage "\n输入容差" "\nInput tolerance")
    "#xd-var-global-equalpoint-tol"
    (xdrx-getvar "equalpoint")
  )
  (xdrx-sysvar-push (list "equalpoint" #xd-var-global-equalpoint-tol))
  (and (setq ss	(xdrx-ssget
		  (xdrx-string-multilanguage
		    "\n选择生成regions的曲线<退出>:"
		    "\nSelect to generate Curves for regions <Exit>:"
		  )
		  '((0 . "*line,arc"))
		)
       )
       (setq ss (xdrx-geom-searchoutline ss))
       (xdrx-prompt
	 (xdrx-string-formatex
	   (xdrx-string-multilanguage
	     "\n生成了 %d 个regions."
	     "\nGenerated %d regions."
	   )
	   (sslength ss)
	 )
       )
  )
  (xdrx-sysvar-pop)
  (xdrx-end)
  (princ)
)

 

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

 

The above code uses XDrx API,

download link:

https://github.com/xdcad/XDrx-API-zip

https://sourceforge.net/projects/xdrx-api-zip/

Dual version link:

https://github.com/xdcad


Yes exactly this, thank you, I will use it and hope it will be valuable to somebody else too

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...