Jump to content

Count number of Polylines near other polylines


asdfgh

Recommended Posts

Hello Everyone,

First I want to thank everyone for helping in this forum, you really inspire me and helped me alot.

 

I have some polylines, long polylines in red and yellow color, and small magenta polylines near the red and yellow polylines, the magenta polylines are near the vertex of the red and yellow polylines by less than 50mm distance. What i want is a lisp to count number of magenta polylines near the yellow polylines and count number of magenta polylines near near red polylines each result is separate ( So the result in this sample should be 6 for yellow and 3 for red). You can find the attached drawing as a reference.

 

Can anyone help with that ?

Thanks is advance.

 

Note: if it is hard to get it, Can there be a lisp to only select the magenta polylines near any polylines i select ?

 

image.png.3c8a75775114e951e7070fa3caf80aa1.png

new block.dwg

Link to comment
Share on other sites

Since everything is on the same layer I splits up the polylines based on their color. then calculate a small area at the endpoints to see if anything magenta polylines are inside.

 

totally useless if the polylines are any other color.

 

(defun C:COUNT (/ )
  (prompt (strcat "\nArrows at yellow Polylines: " (itoa (count 2))))
  (prompt (strcat "\nArrows at red Polylines: " (itoa (count 1))))
  (princ)
)
(defun count (col / c ss ent lst pt1 pt2)
  (setq c 0)
  (if (setq ss (ssget "_X" (list '(0 . "*POLYLINE") (cons 62 col))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq lst (vl-remove-if 'not (mapcar (function (lambda (p) (if (= 10 (car p)) (cdr p)))) (entget ent))))
      (setq pt1 (mapcar '- (car lst) '(100 100)))
      (setq pt2 (mapcar '+ (car lst) '(100 100)))
      (if (ssget "_C" pt1 pt2 '((0 . "*POLYLINE") (62 . 6)))
        (setq c (+ c 1))
      )
      (setq pt1 (mapcar '- (last lst) '(100 100)))
      (setq pt2 (mapcar '+ (last lst) '(100 100)))
      (if (ssget "_C" pt1 pt2 '((0 . "*POLYLINE") (62 . 6)))
        (setq c (+ c 1))
      )
    )
  )
  c
)

 

: COUNT

Arrows at yellow Polylines: 6
Arrows at red Polylines: 3

Edited by mhupp
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

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