Selection filter for DIMENSIONS

Selection filter for DIMENSIONS

MichalHakel_SP
Advocate Advocate
706 Views
4 Replies
Message 1 of 5

Selection filter for DIMENSIONS

MichalHakel_SP
Advocate
Advocate

Hello,

 

I would like to ask for AutoLISP for "filter selection mode - Object=Dimensions".

 

What I have/I do:

  • I use "FILTER" command firstly
  • then I have to select my specific filter to dimensions
  • then click Apply
  • the last step is to select dimensions in my drawing and hit enter to select it excluded everything else in the drawing

What I would like to have:

I would like to do this steps in just one autolisp because of frequency of use this command.

 

I would create Macro for this AUtoLISP command as a new icon on AutoCAD toolbar.

I will click on it, then just select dimensions.

I would like to do this for every category of selection filter by create more macros for every selection filter I need and then just use this icon added to my toolbar isntead of using Filter command and going through the pop-up menu.

 

Thank you in advance

 

 

0 Likes
Accepted solutions (1)
707 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

(sssetfirst nil (ssget '((0 . "DIMENSION"))))

0 Likes
Message 3 of 5

MichalHakel_SP
Advocate
Advocate

Thank you very much 😉

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant

Maybe this you'll find useful too. I use this all the time.

 

;-----
(defun c:FilterSelectionByType ( / i ls2 lst pik ss ss2 typ dsl nxt) ; Filter by type of entity
  
  
  (if (not (setq ss (ssget "_I")))
    (progn
      (command "_.SELECT")
      (while (> (getvar 'CMDACTIVE) 0)
	(command PAUSE))
      (and (setq ss (ssget "_P"))
	   (sssetfirst nil ss))))
  (if ss
    (progn
      (repeat (setq i (sslength ss))
	(setq typ (cdr (assoc 0 (entget (ssname ss (setq i (1- i))))))
	      lst (if (setq ass (assoc typ lst))
		    (subst (cons typ (1+ (cdr ass))) ass lst)
		    (cons (cons typ 1) lst))))
      (setq lst (mapcar 'car (vl-sort lst '(lambda (e1 e2) (> (cdr e1) (cdr e2))))))
      
      (while (progn
	       (initget (substr (apply 'strcat (mapcar '(lambda (x) (strcat " " (itoa (vl-position x lst)))) lst)) 2))
	       (cond ((setq pik (entsel (strcat "\r>> FILTER SELECTION: Select entity [" (substr (apply 'strcat (mapcar '(lambda (x) (strcat "/" (itoa (vl-position x lst)) ":" (strcase x t))) lst)) 2) "] <"(if nxt "done" "DESELECT") ">: "))))
		     (nxt
		      nil)
		     ((setq pik "DESELECT"))))
	(setq pik (if (= 'STR (type pik))
		    (if (= pik "DESELECT")
		      "DESELECT"
		      (nth (atoi pik) lst))
		    (cdr (assoc 0 (entget (car pik)))))
	      ls2 (cond ((= pik "DESELECT")
			 lst)
			((not ls2)
			 (if dsl
			   (member pik lst)
			   (list pik)))
			((member pik ls2)
			 (if dsl
			   (member pik ls2)
			   (vl-remove pik ls2)))
			(T
			 (if dsl
			   (progn
			     (princ (strcat "\n" pic ": already not part of current selection."))
			     ls2)
			   (cons pik ls2))))
	      ss2 (acet-ss-ssget-filter ss (list (cons 0 (substr (apply 'strcat (mapcar '(lambda (x) (strcat "," x)) ls2)) 2)))))
	(sssetfirst nil nil)
	(sssetfirst nil ss2)
	(setq nxt T)
	)))
  (princ (strcat "\nRemained selected: " (substr (apply 'strcat (mapcar '(lambda (x) (strcat "," x)) ls2)) 2)))
  (princ)
  )

 

0 Likes
Message 5 of 5

MichalHakel_SP
Advocate
Advocate

You created Lisp for AutoCAD to "filter works" like in Revit 😁

It seems to be very usefull 😊

 

Thank you once again

 

 

0 Likes