Jump to content

Recommended Posts

Posted (edited)

Is there's a LISP which selects all the intersecting polylines? see the attached cad file. I cannot seem to select the polylines are in the middle because they all have same properties.

 

Drawing3.dwg

Edited by Sandeep RC
  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • Sandeep RC

    14

  • BIGAL

    9

  • Tsuky

    2

Top Posters In This Topic

Posted Images

Posted (edited)

Looks like you want to do something after find all intersections like join 2 plines.

 

Correct ?

 

Then can do that by looking at start and end points if same point then join. A lot of looping.

Edited by BIGAL
  • Sandeep RC changed the title to Select all the intersecting polylines
Posted

@BIGAL It is okay even if i could just select them after running the command, and separate them out from that particular drawing.

Posted

it is okay even if they do not get joined. i just want to somehow select them and copy paste them into new cad file. that is it.

Posted

You still have not explained ! You mean copy the outside plines ? 

Posted

no no, i just want to select those polylines which are in the middle, or i just want to select those polylines which are intersecting to one another. 

Posted

like this. but my actual area is way too big. so i do not want to select manually. it will take hours.

Posted (edited)

Dont think you can do it without a crystal ball, as you have all line work on one layer so any "LOOK FOR" will find outside as well. If inside is on a different layer then yes can be done, go back a few steps hopefully and make the offset lines on another layer then do not need code as Layiso will give you what you want. Is this possible ?

 

A big maybe look left, look right but all linework has to have same offset.

 

Edited by BIGAL
Posted

@BIGAL Okay got it. is there any way or lisp that selects only intersected polylines then? that will do a little help.

Posted

Did you make the offset plines can change their layer when created using  a lisp for offset.

Posted

no no, this is the raw input from client. i did not do anything.

Posted

@BIGAL i found this from @marko_ribar , it only selects the intersecting plines to the one which I click on. but i need the selection of all the intersecting plines.

 

(defun c:fss (/ ssxunlocked ss i e sss)

 (defun ssxunlocked (/ filter elst ss)
   (setq filter "")
   (while (setq elst (tblnext "layer" (null elst)))
     (if (= 4 (logand 4 (cdr (assoc 70 elst))))
       (setq filter (strcat filter (cdr (assoc 2 elst)) ","))
     )
   )
   (and (= filter "")(setq filter "~*"))
   (setq ss (ssget "_X" (list (cons 0 "*") (cons -4 "<not") (cons 8 filter) (cons -4 "not>"))))
   ss
 )

 (defun fastsel (e / ss i ent)
   (vl-load-com)
   (setq ss (ssxunlocked))
   (setq i -1)
   (if (null sss) (setq sss (ssadd)))
   (while (setq ent (ssname ss (setq i (1+ i))))
     (if (not (eq e ent))
       (if (vlax-invoke (vlax-ename->vla-object e) 'intersectwith (vlax-ename->vla-object ent) acextendnone)
         (ssadd ent sss)
       )
     )
   )
   (ssadd e sss)
 )

 (prompt "\nSelect fast selection object(s) with touching for entities on unlocked layers")
 (setq ss (ssget "_:L"))
 (setq i -1)
 (while (setq e (ssname ss (setq i (1+ i))))
   (fastsel e)
 )
 (sssetfirst nil sss)
 (princ)
)

Posted

That is why I am saying its not an easy task need to determine is the pline a middle one then change layer "look left, look right before crossing the road".

 

Will think about it.

Posted

It's not perfect, but can simplify your selection.
Use:
- Select all your polylines (by window or capture)
- Select a central polyline

 

(defun compare (l d l_e / prm new_l)
  (mapcar
    '(lambda (e)
      (mapcar
        '(lambda (x)
          (setq prm
            (cond
              ((equal (cadr x) (vlax-curve-getClosestPointTo e (cadr x) T) d)
                (vlax-curve-getparamatpoint e (trans (cadr x) e 0))
              )
              ((equal (last x) (vlax-curve-getClosestPointTo e (last x) T) d)
                (vlax-curve-getparamatpoint e (trans (last x) e 0))
              )
            )
          )
          (if (and prm (not (member (car x) l_e)))
            (progn
              (ssadd (car x) ss)
              (setq new_l (cons (car x) l_e))
            )
          )
        )
        l
      )
    )
    l_e
  )
  (if new_l new_l nil)
)
(defun list_pt_sel (l_e / dxf_ent)
  (mapcar
    '(lambda (e)
      (setq dxf_ent (entget e))
      (cons
        e
        (mapcar
          '(lambda (x)
            (trans x e 0)
          )
          (mapcar 'cdr
            (vl-remove-if
              '(lambda (x)
                (/= (car x) 10)
              )
              dxf_ent
            )
          )
        )
      )
    )
    l_e
  )
)
(defun c:pl_connect ( / dfzz js_all n e_all js_first ss e_master lst_pt_ori e_other lst_pt l)
  (if (not dfzz) (setq dfzz 1E-08))
  (princ "\nSelect polylines")
  (while (not (setq js_all (ssget '((0 . "LWPOLYLINE"))))))
  (repeat (setq n (sslength js_all))
    (setq e_all (cons (ssname js_all (setq n (1- n))) e_all))
  )
  (princ "\Select ONE central polyline")
  (while (not (setq js_first (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))))
  (setq ss (ssadd))
  (setq e_master (ssname js_first 0))
  (setq ss (ssadd e_master ss))
  (setq lst_pt_ori (list_pt_sel e_all))
  (cond
    (lst_pt_ori
      (setq e_other e_all)
      (setq e_other (vl-remove e_master e_other))
      (cond
        (e_other
          (setq lst_pt (list_pt_sel e_other))
          (setq l (list e_master))
          (while l
            (setq l (compare lst_pt dfzz l))
          )
        )
      )
      (sssetfirst nil ss)
    )
  )
)

 

Posted (edited)

Working on select all and finds central ones. 

 

Ok try this found a couple of problems, the offset can vary and one section has non parallel lines. Could be set up to loop for various offsets, have a go 1st just select all. I updated and does 0.6 and 1.0.

 


https://www.cadtutor.net/forum/topic/77055-select-all-the-intersecting-polylines/

(defun c:centpl ( / ss val lst pt pt2 pt3 ang dum1 dum2)
(defun alg-ang (object pnt)
  (angle '(0. 0. 0.)
     (vlax-curve-getfirstderiv
       object
       (vlax-curve-getparamatpoint
         object
         pnt
       )
     )
  )
)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(command "-layer" "M" "New" "c" 1 "New" "s" "0" "")
(prompt "\nSelect all plines ")
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(while (setq ent1 (entsel "\Pick outside pline Enter to exit "))
(setq pt1 (cadr ent1))
(setq obj1 (vlax-ename->vla-object (car ent1)))
(setq pt1 (vlax-curve-getclosestpointto obj1 pt1))
(setq obj2 (vlax-ename->vla-object (car (entsel "\nPick inside pline "))))
(setq pt2 (vlax-curve-getclosestpointto obj2 pt1))
(setq dist (/ (distance pt1 pt2) 2.0))
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (1- x))))
(setq obj (vlax-ename->vla-object ent))
(vla-put-color obj 256)
(setq len (/ (vla-get-length obj) 2.0))
(setq pt (vlax-curve-getpointatdist obj len))
(command "zoom" "C" pt 15)
(setq ang (alg-ang obj pt))
(setq pt2 (polar pt (- ang (/ pi 2)) dist))
(setq dum1 (ssget pt2))
(setq pt3 (polar pt (+ ang (/ pi 2)) dist))
(setq dum2 (ssget pt3))
(if (or (= dum1 nil)(= dum2 nil))
(princ "\nmiss")
(vla-put-layer obj "New")
)
(setq dum1 nil dum2 nil)
)
(princ)
)
)
(c:centpl)

image.png.8748dbe8499be6b2ee767069b84c7731.png

image.png.fa3568295f52be9de4822d138845a843.png

Edited by BIGAL
Posted

@BIGAL Great work buddy. its is working as intended on plines having offsets you have mentioned. basically the input drawing is about the road. so depending on the road width, outer pline distance from centerline will keep on varying. so i will be happy if the lisp runs regardless of offset distance.

Posted

@Tsuky Just tried your code. looks promising as well. I will test this on various drawings. thank you.

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