Author Topic: Crossing polyline vs Window polyline  (Read 2058 times)

0 Members and 1 Guest are viewing this topic.

Denzuki

  • Guest
Crossing polyline vs Window polyline
« on: October 30, 2015, 06:55:45 PM »
I am trying to create a selection set from a group of angular entities. The problem is that these entities also share a line with several polyline boundaries.
 The Crossing polyline gets entities outside the polyline as well as inside and the Window polyline misses the internal adjacent entities. is there a way to do this?

Code:

  (setq ssel1 (ssget "_CP" '((8 . "C-BLOB")(0 . "LWPOLYLINE"))))
  (alert (strcat "There are " (itoa (sslength ssel1)) " blobs in this selection set."))

I was thinking of offsetting the boundary polyline and then using the offset polyline as the boundary polyline but I thought there has got to be a better way.

Thanks




roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Crossing polyline vs Window polyline
« Reply #1 on: October 31, 2015, 10:13:05 AM »
Does (ssget "_CP" ...) without a point list even work? In BricsCAD ssel1 will always be nil.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Crossing polyline vs Window polyline
« Reply #2 on: November 02, 2015, 01:32:21 AM »

Denzuki

  • Guest
Re: Crossing polyline vs Window polyline
« Reply #3 on: November 05, 2015, 05:29:35 PM »
The LeeMac article gave me a better understanding of the SS options to grab the entities. Thanks. What I need is to be able to choose the entities with a selection set, choose a predefined polyline as the boundary for these entities (I have a point list) and count the entities within that polyline, even if the polyline and entities share a common vector. This is what I have, I just don't know how to bring them together. Thanks

 (defun cdrs (key lst / pair rtn)
 (while (setq pair (assoc key lst))
 (setq rtn (cons (cdr pair) rtn)
 lst (cdr (member pair lst))
 )
 )
 (reverse rtn)
 )

  (cdrs 10 (entget (car (entsel "\nSelect a polyline: "))))
  (setq bdrsel1 (list entlast))

 (defun massoc (lst key)
 (vl-remove-if-not '(lambda (x) (= (car x) key)) lst)
 ) ;_ end of defun massoc 

(setq sel1 (ssget '((8 . "C-BLOB") (0 . "LWPOLYLINE"))))
  (alert (strcat "There are " (itoa (sslength sel1)) " blobs in this selection set."))

Denzuki

  • Guest
Re: Crossing polyline vs Window polyline
« Reply #4 on: November 05, 2015, 06:38:47 PM »
BTW, the polyline boundary will not contain arcs, ever.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Crossing polyline vs Window polyline
« Reply #5 on: November 06, 2015, 06:36:23 AM »
There is no (ssget) mode to select entities inside a polygon that also includes entities that touch, but do not intersect the polygon. If the points for the polygon are taken from an actual polyline, the easiest way to work around this is to create a temporary polyline with an offset. Another solution would be to create two selection sets: a "_WP" set and a "_F" set, and analyse the last set to determine if element touch or intersect.

Note that the points in the point list have to be visible on screen for (ssget) to work properly.

Example of the 'Offset approach':
Code - Auto/Visual Lisp: [Select]
  1. (defun OffsetBigger (enme dist / new obj)
  2.   (setq obj (vlax-ename->vla-object enme))
  3.   (if
  4.     (and
  5.       (setq new (car (vlax-safearray->list (vlax-variant-value (vla-offset obj dist)))))
  6.       (< (vla-get-length obj) (vla-get-length new))
  7.     )
  8.     (vlax-vla-object->ename new)
  9.     (progn
  10.       (vla-delete new)
  11.       (vlax-vla-object->ename (car (vlax-safearray->list (vlax-variant-value (vla-offset obj (- dist))))))
  12.     )
  13.   )
  14. )
  15.  
  16. (defun c:test ( / enme new ptLst ss)
  17.   (if
  18.     (and
  19.       (setq enme (car (entsel)))
  20.       (= "LWPOLYLINE" (cdr (assoc 0 (entget enme))))
  21.     )
  22.     (progn
  23.       (setq new (OffsetBigger enme 0.0001)) ; Create temporary polyline.
  24.       (setq ptLst (mapcar 'cdr (vl-remove-if-not '(lambda (sub) (= 10 (car sub))) (entget new))))
  25.       (entdel new) ; Delete temporary polyline.
  26.       (if (setq ss (ssget "_WP" ptLst))
  27.         (sslength ss)
  28.       )
  29.     )
  30.   )
  31. )

BTW: Can you please use code-tags?

Denzuki

  • Guest
Re: Crossing polyline vs Window polyline
« Reply #6 on: November 06, 2015, 10:21:38 AM »
Thank you Roy_043,

After some more re-reading yesterday, I started to code as you suggested by using an offset method. I'm glad to see that I wasn't going crazy. I like your code better for the offset. And I will use the code tag from now on.
I want to apply a zoom to boundary approach to always get the boundary. I will let you know how it comes out.

Thanks again.