Jump to content

Lisp on how to select the Polygon (close polyline) using a point inside this polygon (polyline)?


Recommended Posts

Posted (edited)

Gentlemen,

 

Lisp on how to select the Polygon (close polyline) using a point inside this polygon (polyline)?

 

The issue I have now is that I have about 5K parcels of land, they are already numbered sequentially using a text inside each individual parcel.

I need to generate the land deeds later on but the coordinates points has to process to all parcels.

These points will be an incrementing sequence of points.

 

My program will process by just incrementing number to find the parcel number to find the text, get its location (text insertion point) and find the enclosing polygon.

 

BR,

Manny

Edited by mannybmanago
Posted

There was a similar topic that Steal text inside polyline. Not really much tweaking, but here:

 

(defun c:polypoint ( / *error* acadobj activeundo adoc catch insidepoly msp osm pls pt ray)
    
    (defun *error* ( msg )
	(setvar 'osmode osm)
	(if (and (eq (type ray) 'vla-object) (null (vlax-erased-p ray))) (vl-catch-all-apply 'vla-delete (list ray)))
	(vla-EndUndoMark adoc)
	(if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*"))
	    (princ (strcat "Error: " msg))
	    )
	)
    
    (defun insidepoly (pt ent ray / ints)
	(setq ints (vlax-invoke (vlax-ename->vla-object ent) 'intersectwith ray acExtendNone))
	(if (eq (rem (length ints) 6) 3) ent)
	)
    
    (setq acadobj (vlax-get-acad-object)
	  adoc (vla-get-ActiveDocument acadobj)
	  msp (vla-get-ModelSpace adoc)
	  activeundo nil)
    (if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T))
    
    (setq osm (getvar 'osmode))
    (setvar 'osmode 0)
    (setq pt (progn (initget 1) (getpoint "\nSpecify point: "))
	  ray (vla-AddRay msp (vlax-3d-point pt) (vlax-3d-point (polar pt 0 1)))
	  pls (ssget "_X" '((0 . "LWPOLYLINE") (70 . 1)))
	  )

    (if
	(setq catch
		 (vl-some
		     '(lambda (x)
			  (insidepoly pt x ray)
			  )
		     (JH:selset-to-list pls)
		     )
	      )
	(sssetfirst nil (ssadd catch))
	)

    (vla-delete ray)
    (setvar 'osmode osm)
    (if activeundo nil (vla-EndUndoMark adoc))
    (princ)
    )

(defun JH:selset-to-list (selset / lst iter) ; Returns all entities within a selection set into a list.
    (if selset
	(repeat (setq iter (sslength selset))
	    (setq lst (cons (ssname selset (setq iter (1- iter))) lst))
	    )
	)
    )

 

  • Thanks 1
Posted (edited)

"I need to generate the land deeds later on"

 

Just a comment I answered this problem a few years ago now, it would make a copy of each lot and so a layout per lot could be created. Getting co-ords and dumping to a file I think was also done as well as co-ord list per lot diplayed. Will have a look for it.

 

I am pretty sure went the easier way and found the text inside the polygon, sort a list ((lotno ename)…)

 

Edited by BIGAL
Posted

Still looking pretty sure does what you want. Some code I lost when changed to retired. Pretty sure was here.

 

This is lots to table. 

Table of lots.lsp

  • Thanks 1
Posted (edited)

Hi Jonathan,

 

I just  tested the code and it works by picking a point...let me see if I can integrate it to my code.

In my case, I will have about almost 5k plots or parcels, they are already numbered.

My routine is not as advance as yours, and maybe be crude is many ways.

I will send it to you once I have it working.

Thanks a lot!

 

BR,

Manny

 

On 4/29/2020 at 7:31 PM, Jonathan Handojo said:

There was a similar topic that Steal text inside polyline. Not really much tweaking, but here:

 


(defun c:polypoint ( / *error* acadobj activeundo adoc catch insidepoly msp osm pls pt ray)
    
    (defun *error* ( msg )
	(setvar 'osmode osm)
	(if (and (eq (type ray) 'vla-object) (null (vlax-erased-p ray))) (vl-catch-all-apply 'vla-delete (list ray)))
	(vla-EndUndoMark adoc)
	(if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*"))
	    (princ (strcat "Error: " msg))
	    )
	)
    
    (defun insidepoly (pt ent ray / ints)
	(setq ints (vlax-invoke (vlax-ename->vla-object ent) 'intersectwith ray acExtendNone))
	(if (eq (rem (length ints) 6) 3) ent)
	)
    
    (setq acadobj (vlax-get-acad-object)
	  adoc (vla-get-ActiveDocument acadobj)
	  msp (vla-get-ModelSpace adoc)
	  activeundo nil)
    (if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T))
    
    (setq osm (getvar 'osmode))
    (setvar 'osmode 0)
    (setq pt (progn (initget 1) (getpoint "\nSpecify point: "))
	  ray (vla-AddRay msp (vlax-3d-point pt) (vlax-3d-point (polar pt 0 1)))
	  pls (ssget "_X" '((0 . "LWPOLYLINE") (70 . 1)))
	  )

    (if
	(setq catch
		 (vl-some
		     '(lambda (x)
			  (insidepoly pt x ray)
			  )
		     (JH:selset-to-list pls)
		     )
	      )
	(sssetfirst nil (ssadd catch))
	)

    (vla-delete ray)
    (setvar 'osmode osm)
    (if activeundo nil (vla-EndUndoMark adoc))
    (princ)
    )

(defun JH:selset-to-list (selset / lst iter) ; Returns all entities within a selection set into a list.
    (if selset
	(repeat (setq iter (sslength selset))
	    (setq lst (cons (ssname selset (setq iter (1- iter))) lst))
	    )
	)
    )

 

 

Edited by mannybmanago
Posted

So you're saying you actually want to select the polygon using the insertion points of the texts?

 

Certainly doable, but program will take really long, especially with 5k parcels, need to check every single polyline in the drawing... You're better off selecting the polyline and getting the text inside rather than getting the text then the polyline. It's a lot quicker that way.

Posted

Mannybmanago did you have a look at the code I posted it is the final step of pulling individual lots out, it was tested on say 100+ lots. "I need to generate the land deeds later on"

 

Please post a dwg ! For testing.

 

How are the land deeds drawn need a sample dwg or is it dwgs? If that's the case that's what I posted one code is 1 dwg the other all new dwgs.

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