Intersecting polylines to be select and Layer name to Label with same layer name

Intersecting polylines to be select and Layer name to Label with same layer name

Hannan1
Advocate Advocate
2,504 Views
13 Replies
Message 1 of 14

Intersecting polylines to be select and Layer name to Label with same layer name

Hannan1
Advocate
Advocate

Can any body help me in this causes ,
I want to select all polylines (or all entities Etc.) which is intersecting to selected Polyline,
And the Other thing is that
I want to Place a layer Name Lable on the Polyline with the same layer name Like Polyline layer should be lable layer name is this can be happen with multiple selection
For this any Lisp is there.

0 Likes
Accepted solutions (1)
2,505 Views
13 Replies
Replies (13)
Message 2 of 14

SeeMSixty7
Advisor
Advisor

Can you upload an image of before and after of what you are looking for?

 

Good luck,

0 Likes
Message 3 of 14

Hannan1
Advocate
Advocate

Please Check the Screenshort Capture.JPG

0 Likes
Message 4 of 14

Hannan1
Advocate
Advocate

Please check Before and After Screenshort Capture 2 file name attachedCapture 2.JPG

0 Likes
Message 5 of 14

Ranjit_Singh
Advisor
Advisor

Here's one example that might work for you.

;;Add layer names to lines/polylines
;;Ranjit Singh
;;5/11/17
(defun c:somefunc (/ curosmode vlaobj ent ss1) (setq curosmode (getvar 'osmode)) (setvar 'osmode 16384) (command "._zoom" "_obj" (setq ent (car (entsel "\nSelect intersecting polyline: "))) "") (mapcar '(lambda (x) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") (cons 8 (caddr x)) '(100 . "AcDbMText") (cons 10 (cadddr x)) (cons 1 (caddr x)) '(7 . "ROMANS") (cons 50 (car x)) '(71 . 8)))) (mapcar '(lambda (x) (setq vlaobj (vlax-ename->vla-object (car x))) (cons (angle '(0 0) (car (mapcar '(lambda (x) (if (minusp (car x)) (mapcar '* '(-1 -1) x) x)) (list (vlax-curve-getfirstderiv vlaobj (vlax-curve-getparamatpoint vlaobj (vlax-curve-getclosestpointto vlaobj (last x)))))))) x)) (mapcar '(lambda (x) (cons (cadr x) (cons (cdr (assoc 8 (entget (cadr x)))) (cdr (cadddr x))))) (vl-remove-if '(lambda (x) (equal ent (cadr x))) (ssnamex (setq ss1 (ssget "_f" (cdr (reverse (vl-remove-if-not 'listp (mapcar 'cdr (entget ent))))) '((0 . "*LINE"))))))))) (setvar 'osmode curosmode) (sssetfirst nil (ssdel ent ss1)) (princ))

 

Message 6 of 14

stevor
Collaborator
Collaborator

So Hannan1, did the c:somefunc of Ranjit work for you?

If not, for more suggestions, 

post a simple DWG, small and old format.

S
0 Likes
Message 7 of 14

Hannan1
Advocate
Advocate

Its not working the Error is like ( Command: ; error: bad argument type: lselsetp nil )

0 Likes
Message 8 of 14

Hannan1
Advocate
Advocate

Please find the DWG sample file.

0 Likes
Message 9 of 14

Ranjit_Singh
Advisor
Advisor
Accepted solution

Your lines are 2d polylines and I designed my program for line and lwpolyline. That's why you should always post a drawing 🙂 See updated code below. See the screencast.

(defun c:somefunc  (/ curosmode vlaobj ent ent2 etdata lst ss1)
 (setq curosmode (getvar 'osmode))
 (setvar 'osmode 16384)
 (command "._zoom" "_obj" (setq ent (car (entsel "\nSelect intersecting polyline: "))) "")
 (setq etdata (entget (setq ent2 ent)))
 (cond ((= "POLYLINE" (cdr (assoc 0 etdata)))
        (while (/= "SEQEND" (cdr (assoc 0 (setq etdata (entget (setq ent (entnext ent)))))))
         (setq lst (cons (cdr (assoc 10 etdata)) lst))))
       ((wcmatch (cdr (assoc 0 etdata)) "LINE,LWPOLYLINE")
        (setq lst (cdr (reverse (vl-remove-if-not 'listp (mapcar 'cdr etdata))))))
       (t ()))
 (if lst
  (mapcar '(lambda (x)
            (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") (cons 8 (caddr x)) '(100 . "AcDbMText") (cons 10 (cadddr x)) (cons 1 (caddr x)) '(7 . "ROMANS") (cons 50 (car x)) '(71 . 8))))
          (mapcar '(lambda (x)
                    (setq vlaobj (vlax-ename->vla-object (car x)))
                    (cons (angle '(0 0)
                                 (car
                                  (mapcar '(lambda (x)
                                            (if (minusp (car x))
                                             (mapcar '* '(-1 -1) x)
                                             x))
                                          (list
                                           (vlax-curve-getfirstderiv vlaobj
                                                                     (vlax-curve-getparamatpoint vlaobj (vlax-curve-getclosestpointto vlaobj (last x))))))))
                          x))
                  (mapcar '(lambda (x) (cons (cadr x) (cons (cdr (assoc 8 (entget (cadr x)))) (cdr (cadddr x)))))
                          (vl-remove-if '(lambda (x) (equal ent2 (cadr x)))
                                        (ssnamex (setq ss1 (ssget "_f" lst '((0 . "*LINE"))))))))))
 (setvar 'osmode curosmode)
 (sssetfirst nil (ssdel ent ss1))
 (princ))

Message 10 of 14

Hannan1
Advocate
Advocate

Thank you very much Ranjit.Singh for this it was work for me .

But One more thinks is there Which is that i would like to select those polyline which is intersecting to the selected polyline.

Bcoz. i want to copy those lines tho new drawing file .

This Code i can accept solve .

0 Likes
Message 11 of 14

Ranjit_Singh
Advisor
Advisor

@Hannan1 wrote:

............ i would like to select those polyline which is intersecting to the selected polyline....


Change this line

(sssetfirst nil (ssdel ent ss1))

to

(sssetfirst nil (ssdel ent2 ss1))

I cannot test it since I am away from my computer but I am pretty sure it will work. Give it a try. I will also check [tomorrow] if it works.

Message 12 of 14

Hannan1
Advocate
Advocate

Thank you very much Sir...

Its is work Very nice 

Thanks thanks

0 Likes
Message 13 of 14

Ranjit_Singh
Advisor
Advisor

You are welcome 🙂

0 Likes
Message 14 of 14

Hannan1
Advocate
Advocate

One more help Plz,,

If i want Add vertex on intersecting points in selected polyline.

0 Likes