Select the similiar by layer

Select the similiar by layer

F.Camargo
Advisor Advisor
2,482 Views
12 Replies
Message 1 of 13

Select the similiar by layer

F.Camargo
Advisor
Advisor

Hi friends! 🙂

 

I'm trying to use select the similiar to select all lines, polylines, arcs from a layer.

Anybody could help me please!?

 

SelectSimilar command select just one at the time.

And I'd like to select all the lines, polylines, arc and circle.

 

Thank in advance

Fabrício

0 Likes
Accepted solutions (1)
2,483 Views
12 Replies
Replies (12)
Message 2 of 13

john.uhden
Mentor
Mentor

I have a Griplayer command I use all the time.  You pick one object and it grips (selects) all the objects on that layer in the current space and reports how many it gripped.

 

Or do you want to restrict the selection to just lines, arcs, circles, and polylines?

 

Or if you pick a circle, do you want it to select just all the circles on that layer?  And the same for lines, etc?

John F. Uhden

0 Likes
Message 3 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

@F.Camargo wrote:

.... 

I'm trying to use select the similiar to select all lines, polylines, arcs from a layer.

.... 

SelectSimilar command select just one at the time.

And I'd like to select all the lines, polylines, arc and circle.

....


I don't think there's an option in SELECTSIMILAR to do what you're after [at least, I don't see a way in its dialog box].  You would probably need something like an AutoLisp routine.  Minimally tested:

 

(defun C:SLPACL ; = Select Lines/Polylines/Arcs/Circles on Layer of selected object
  (/ esel)
  (if (setq esel (entsel "\nSelect object to find all Lines/Polylines/Arcs/Circles on its Layer: "))
    (sssetfirst nil
(ssget "_X" (list '(0 . "LINE,ARC,CIRCLE,*POLYLINE") (assoc 8 (entget (car esel))) (cons 410 (getvar 'ctab))))
) ) )

 

Kent Cooper, AIA
Message 4 of 13

phanaem
Collaborator
Collaborator

F.Camargo wrote:

SelectSimilar command select just one at the time.

And I'd like to select all the lines, polylines, arc and circle.


Select Similar can select multiple object types. Just grip at least one object of each type, then call SelectSimilar.

 

0 Likes
Message 5 of 13

F.Camargo
Advisor
Advisor

@Kent1Cooper wrote:

@F.Camargo wrote:

.... 

I'm trying to use select the similiar to select all lines, polylines, arcs from a layer.

.... 

SelectSimilar command select just one at the time.

And I'd like to select all the lines, polylines, arc and circle.

....


I don't think there's an option in SELECTSIMILAR to do what you're after [at least, I don't see a way in its dialog box].  You would probably need something like an AutoLisp routine.  Minimally tested:

 

(defun C:SLPACL ; = Select Lines/Polylines/Arcs/Circles on Layer of selected object
  (/ esel)
  (if (setq esel (entsel "\nSelect object to find all Lines/Polylines/Arcs/Circles on its Layer: "))
    (sssetfirst nil
(ssget "_X" (list '(0 . "LINE,ARC,CIRCLE,*POLYLINE") (assoc 8 (entget (car esel))) (cons 410 (getvar 'ctab))))
) ) )

 


Hi,

 

That code worked like a charm!!!  Smiley Happy

 

Thank you very much @Kent1Cooper

 

Fabrício

0 Likes
Message 6 of 13

3wood
Advisor
Advisor

Firstly, you can make SELECTSIMILAR work. There is a setting option in SELECTSIMILAR command.

Capture2.JPGYou can select 

 

Secondly, you can use QSELECT.

 

QSELECT:

Capture.JPG

 

Thirdly, you can also use FILTER.

FILTER:

Capture 2.JPG

 You can save the filter and use it in other drawings.

Message 7 of 13

F.Camargo
Advisor
Advisor

@3wood wrote:

Firstly, you can make SELECTSIMILAR work. There is a setting option in SELECTSIMILAR command.

Capture2.JPGYou can select 

 

Secondly, you can use QSELECT.

 

QSELECT:

Capture.JPG

 

Thirdly, you can also use FILTER.

FILTER:

Capture 2.JPG

 You can save the filter and use it in other drawings.


Hi @3wood

 

Qselect isn't working as I expected.

 

Very nice Filter command, I hadn't ever used it. But isn't working too.

 

Filter.PNG

 

 

 It isn't select any object. Smiley Frustrated

 

 

Thanks

0 Likes
Message 8 of 13

cadffm
Consultant
Consultant

Filter:

Because no Object is a arc a line and a polyline at the same time 😉

 

 

beginn OR

object = line

object = arc

object=polyline

end OR

layer=mylayer

 

[apply]

 

ALL<enter><enter>

Sebastian

Message 9 of 13

ВeekeeCZ
Consultant
Consultant

@F.Camargo wrote:

 

...

SelectSimilar command select just one at the time.

And I'd like to select all the lines, polylines, arc and circle.

 

..

I think its a pity that its not possible. Sometime it is useful -- In my case, if I am sorting the line work coming from converted dgn, I usually convert all the line work to polylines first to take further benefit of quick selecting using SelectSimilar by other properties then object type -- usually by layer, color a linetype.

 

Anyway, I thought I might be a nice routine to add this feature (and still keep the setting of the original Select Similar command.

Notes: 

- ignors object type differences
- ignors object style (selectsimilarmode 62)
- ignors object name (selectsimilarmode 128)

- no object pre-selection allows you change the setting (using the original Select Similar setting dialog)

- object pre-selection skips the setting

- multiple selection allowed

 

;; the routine takes the setting from built-in SelectSimilar command except
;; - ignors object type differences
;; - ignors object style (selectsimilarmode 62)
;; - ignors object name (selectsimilarmode 128)

;; BeekeeCZ 2018-01-25

(vl-load-com)

(defun c:SSTypeIgnored ( / lst ss sn mode mods i new old ed en)
  
  (if (and (or (>= (atof (getvar 'acadver)) 18.1)
               (prompt "\nError: The routine is using the setting of the SelectSimilar command available since AutoCAD 2011."))
           (or (and (not (ssget "_I"))
                    (vl-cmdf "_.SELECTSIMILAR" "_Settings" ""))
               T)
           (setq ss (ssget))
           (setq mode (getvar 'selectsimilarmode)
                 mods (mapcar 'cdr (vl-remove-if-not '(lambda (m) (= (car m) (logand mode (car m))))
                                     '((1 . 62)
                                       (1 . 420)
                                       (2 . 8)
                                       (4 . 6)
                                       (8 . 48)
                                       (16 . 370)
                                       (32 . 390)))))
           )
    (progn
      (repeat (setq i (sslength ss))
        (setq ed (entget (ssname ss (setq i (1- i)))))
        (foreach m mods
          (setq new (cond ((assoc m ed)
                           (cdr (assoc m ed))))
                lst (if (setq old (assoc m lst))
                      (subst (cons m (if (member new (cdr old))
                                       (cdr old)
                                       (cons new (cdr old))))
                             old
                             lst)
                      (cons (list m new) lst)))))
      
      (setq sn (ssadd)
            ss (ssget "_X" (list (cons 410 (getvar 'CTAB)))))
      (repeat (setq i (sslength ss))
        (setq ed (entget (setq en (ssname ss (setq i (1- i))))))
        (if (not (member 'nil (mapcar '(lambda (x) (member (cond ((assoc (car x) ed)
                                                                  (cdr (assoc (car x) ed))))
                                                           (cdr x)))
                                      lst)))
          (ssadd en sn)))
      (vla-regen (vla-get-activedocument (vlax-get-acad-object)) 1)
      (princ (strcat "\nMatching by: "
                     (vl-string-trim ", " (apply 'strcat (mapcar 'cdr (vl-remove-if-not
                                                                        '(lambda (m) (= (car m) (logand mode (car m))))
                                                                        '((1 . "COLOR, ") (2 . "LAYER, ") (4 . "LineType, ") (8 . "LT Scale, ") (16 . "LineWeight, ") (32 . "PlotStyle, "))))))))
      (sssetfirst nil sn)))
  (princ)
  )

Message 10 of 13

Kent1Cooper
Consultant
Consultant

@3wood wrote:

Firstly, you can make SELECTSIMILAR work. There is a setting option in SELECTSIMILAR command.

....

 

Secondly, you can use QSELECT.

 

Thirdly, you can also use FILTER.

....


The SELECTSIMILAR approach with the options checked would require finding all Lines with one selection, all Polylines with another, etc. -- it won't find different entity types together.

 

The QSELECT approach filtering by Layer will also find any things other than the desired entity types [Splines, Text, Viewports, ...] that may be on that Layer.

 

I like the FILTER approach best of those suggestions for those reasons, but it also has the small disadvantage that you still have to Select [either before calling up FILTER or after hitting Apply] the range of stuff from which you want it to filter out those objects -- not too difficult to not pre-select and just type ALL after hitting Apply, but still....  The AutoLisp routine finds them all without that, immediately upon calling it.

 

But the AutoLisp routine has the disadvantage, if you need different combinations of entity types and Layers at different times, that it needs a specific combination built into it, whereas FILTER lets you set up whatever combination you want any time.  The routine could be made in a generic  way, to ask for entity type(s) and Layer when you use it, but then its other advantage is lost, and you may as well just use FILTER.

Kent Cooper, AIA
Message 11 of 13

F.Camargo
Advisor
Advisor

It worked!!

 

Thanks

Fabrício

0 Likes
Message 12 of 13

3wood
Advisor
Advisor

Kent1Cooper wrote:

The SELECTSIMILAR approach with the options checked would require finding all Lines with one selection, all Polylines with another, etc. -- it won't find different entity types together.

 

The QSELECT approach filtering by Layer will also find any things other than the desired entity types [Splines, Text, Viewports, ...] that may be on that Layer.


SELECTSIMILAR runs perfectly in my AutoCAD 2017. Just select 1 line, 1 arc, and 1 polyline in one go (them can be in different layers) and SELECTSIMILAR finds out the rest for you.

 

When you are using QSELECT, you need repeat it a few times and tick"Append to current selection set" option to append different objects into previous selection set.

0 Likes
Message 13 of 13

3wood
Advisor
Advisor

You need copy exactly what's shown in my FILTER screenshot and only change the layer name to yours.