Select polyline same lintype and layer

Select polyline same lintype and layer

virgilius99
Contributor Contributor
474 Views
6 Replies
Message 1 of 7

Select polyline same lintype and layer

virgilius99
Contributor
Contributor

Hi, i need some help with a lisp, here i go:

 

I need a lisp for autocad that can do the following steps:
1. let me choose a polyline
2. search in the drawing and select all the polylines according to the same linetype and layer that i chose in point 1

 

PS: I know that Quickselect exist, but i need a shortcut, thank you!

0 Likes
Accepted solutions (2)
475 Views
6 Replies
Replies (6)
Message 2 of 7

komondormrex
Mentor
Mentor
Accepted solution

hi,

try this

(setq pline_dxf  (entget (car (entsel "\nPick sample pline: "))))
(sssetfirst nil (setq all_qualified_plines (ssget "_x" (vl-remove nil (list (assoc 0 pline_dxf) (assoc 6 pline_dxf) (assoc 8 pline_dxf))))))
0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant

EDITED:

If you're talking about ones that have a linetype override, then @komondormrex 's approach should work, but I think not if the selected source object is ByLayer in linetype, because there will be no entry for linetype in the entity data to filter for, so it will find all objects of the same type and Layer, no matter what their linetype.

Kent Cooper, AIA
0 Likes
Message 4 of 7

virgilius99
Contributor
Contributor

It works, but like a command type line, how do i take it to a lisp instead?

0 Likes
Message 5 of 7

virgilius99
Contributor
Contributor

Resolved, thank you for your time!

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@Kent1Cooper wrote:

If you're talking about ones that have a linetype override, then @komondormrex 's approach should work, but I think not if the selected source object is ByLayer in linetype, because ... it will find all objects of the same type and Layer, no matter what their linetype.


This seems to overcome that issue with a source object of ByLayer Linetype, in limited testing:

 

(defun C:SSTLL (/ edata n ent); = Selection Set of same object Type, Layer & Linetype
  (setq edata (entget (car (entsel "\nSample object: "))))
  (setq SameTypeLayerLtype
    (ssget "_X"
      (if (assoc 6 edata)
        (list (assoc 0 edata) (assoc 8 edata) (assoc 6 edata)); then -- all 3
        (list (assoc 0 edata) (assoc 8 edata)); else -- by Type & Layer only
      ); if
    ); ssget
  ); setq
  (if (not (assoc 6 edata)); if source is ByLayer Linetype, remove any with override
    (repeat (setq n (sslength SameTypeLayerLtype))
      (setq ent (ssname SameTypeLayerLtype (setq n (1- n))))
      (if (assoc 6 (entget ent)) (ssdel ent SameTypeLayerLtype))
    ); repeat
  ); if
  (sssetfirst nil SameTypeLayerLtype); select/grip/highlight
); defun

 

And it works for any kind of object.  There may be a more concise way to do it -- I was hoping for a relational test with (-4) entries, but didn't find a way.

Kent Cooper, AIA
0 Likes
Message 7 of 7

virgilius99
Contributor
Contributor

Thank you

0 Likes