jr.roberto.santos Posted May 27, 2022 Share Posted May 27, 2022 List Box with Filter | Lee Mac Programming (lee-mac.com) http://www.lee-mac.com/filtlistbox.html Dear I would like a help to list the values of the attributes. Is that possible? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Example: DWG with...: Block1: AttributeX Value: Item 1 AttributeX Value: Item 2 AttributeX Value: Item 3 . . . Select an Item: Item 1 Item 2 Item 3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Best Regards Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 27, 2022 Share Posted May 27, 2022 This will make a list of the attributes in a block. You can use this list in the Lee-mac code. (setq obj (vlax-ename->vla-object (car (entsel "Pick blk")))) (setq atts (vlax-invoke obj 'Getattributes)) (setq lst '()) (foreach att atts (setq lst (cons (vla-get-textstring att) lst)) ) 2 Quote Link to comment Share on other sites More sharing options...
jr.roberto.santos Posted June 3, 2022 Author Share Posted June 3, 2022 On 5/27/2022 at 5:21 PM, BIGAL said: This will make a list of the attributes in a block. You can use this list in the Lee-mac code. (setq obj (vlax-ename->vla-object (car (entsel "Pick blk")))) (setq atts (vlax-invoke obj 'Getattributes)) (setq lst '()) (foreach att atts (setq lst (cons (vla-get-textstring att) lst)) ) Dear @BIGAL Thanks for the return. I used the @Lee Mac sample code. Works well for the layers but I'd like to list the attributes. ;;;;;;;; (defun c:test ( / def lst ) (while (setq def (tblnext "layer" (not def))) (setq lst (cons (cdr (assoc 2 def)) lst)) ) (LM:filtlistbox "Select a Layer" (acad_strlsort lst) t) ) ;;;;; Best regards. Quote Link to comment Share on other sites More sharing options...
exceed Posted June 3, 2022 Share Posted June 3, 2022 32 minutes ago, jr.roberto.santos said: Dear @BIGAL Thanks for the return. I used the @Lee Mac sample code. Works well for the layers but I'd like to list the attributes. ;;;;;;;; (defun c:test ( / def lst ) (while (setq def (tblnext "layer" (not def))) (setq lst (cons (cdr (assoc 2 def)) lst)) ) (LM:filtlistbox "Select a Layer" (acad_strlsort lst) t) ) ;;;;; Best regards. BIGAL has already given you the answer. did you try it? (defun c:test ( / lst atts obj ) (setq obj (vlax-ename->vla-object (car (entsel "Pick blk")))) (setq atts (vlax-invoke obj 'Getattributes)) (setq lst '()) (foreach att atts (setq lst (cons (vla-get-textstring att) lst)) ) (LM:filtlistbox "Select a Layer" (acad_strlsort lst) t) ) ;; Filtered List Box - Lee Mac ;; Displays a list box interface from which the user may select one or more items. ;; Includes an edit box filter to enable the user to filter the displayed list of items. ;; msg - [str] List box dialog title ;; lst - [lst] List of strings to display in the list box ;; mtp - [bol] T=Allow multiple items; nil=Single item selection ;; Returns: [lst] List of selected items, else nil (defun LM:filtlistbox ( msg lst mtp / _addlist dch dcl des rtn sel tmp ) (defun _addlist ( key lst ) (start_list key) (foreach x lst (add_list x)) (end_list) lst ) (if (and (setq dcl (vl-filename-mktemp nil nil ".dcl")) (setq des (open dcl "w")) (write-line (strcat "filtlistbox : dialog { label = \"" msg "\"; spacer;" ": list_box { key = \"lst\"; width = 50; fixed_width = true; height = 15; fixed_height = true; allow_accept = true; " "multiple_select = " (if mtp "true" "false") "; }" ": edit_box { key = \"flt\"; width = 50; fixed_width = true; label = \"Filter:\"; }" "spacer; ok_cancel; }" ) des ) (not (close des)) (< 0 (setq dch (load_dialog dcl))) (new_dialog "filtlistbox" dch) ) (progn (_addlist "lst" (setq tmp lst)) (set_tile "lst" (setq rtn "0")) (set_tile "flt" "*") (action_tile "lst" "(setq rtn $value)") (action_tile "flt" (vl-prin1-to-string '(progn (setq flt (strcat "*" (strcase $value) "*") sel (mapcar '(lambda ( n ) (nth n tmp)) (read (strcat "(" rtn ")"))) ) (_addlist "lst" (setq tmp (vl-remove-if-not '(lambda ( x ) (wcmatch (strcase x) flt)) lst))) (set_tile "lst" (setq rtn (vl-string-trim "()" (vl-princ-to-string (cond ( (vl-sort (vl-remove nil (mapcar '(lambda ( x ) (vl-position x tmp)) sel)) '<)) ( '(0) ) ) ) ) ) ) ) ) ) (setq rtn (if (= 1 (start_dialog)) (mapcar '(lambda ( x ) (nth x tmp)) (read (strcat "(" rtn ")"))) ) ) ) ) (if (< 0 dch) (setq dch (unload_dialog dch)) ) (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl) ) rtn ) Quote Link to comment Share on other sites More sharing options...
jr.roberto.santos Posted June 3, 2022 Author Share Posted June 3, 2022 @BIGAL Yes you had already responded using the "Pick blk" for a single block. In this example, I'm trying to select all blocks and filter only the non-duplicate "MFG" attribute. Please find the attached file. Best regards. SAMPLE.dwg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.