Author Topic: Selection Set by Block Name and Filter by Layer Name...  (Read 5306 times)

0 Members and 1 Guest are viewing this topic.

dortega4269

  • Guest
Selection Set by Block Name and Filter by Layer Name...
« on: August 08, 2014, 06:05:03 PM »
I had help with a bit of routine to help me create a Selection Set by Block Name and Filter by Layer Name on another site http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Selection-Set-by-block-name/m-p/5192827#M324878, I had lots of help by Tharwat, but I was unable to successfully explain my situation effectively, so he opted to bow out.

If there is anyone that is willing to help me finish this I'd greatly appreciate it.

Here's what I'm looking to do to extend this routine a bit further:
  • Currently I select any block within a drawing and all blocks with that name are selected (ex: Select Block named Casework --> All Casework blocks are selected)
  • On the Layer Popup_List I receive a full list of layers in the drawing --> I would like to minimize the Layer list to show only layers used by Casework block(s)
These are the options I'd like to receive on the Layers List
  • When "-- On Any Layer --" is selected all Casework blocks are selected
  • When a specific layer is selected, 34" Tall Base Cabinet, then only the Casework blocks on the 34" Tall Base Cabinet layer are selected

Code: [Select]
(defun c:GetBlocks (/ *error* D f id run go sel layers blocks s lst ss i sn bn go BlockTable LayerTable)
  ;; Author: Tharwat Al Shoufi ;;
  ;; GetBlocks Program ;;
  ;; Date : 04. August. 2014 ;;
  (defun *error* (msg)
    (if (and D (setq D (findfile D)))
      (vl-file-delete D)
    )
    (if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")
      (princ msg)
      (princ (strcat "\n ** Error : " msg " **"))
    )
  )
  ;; ;;
  (defun BlockTable (/ i a l nm)
    (while (setq i (tblnext "BLOCK" (not i)))
      (if (not (wcmatch (setq nm (cdr (assoc 2 i))) "`**"))
        (setq l (cons nm l))
      )
    )
    (setq l (acad_strlsort l))
  )
  ;; ;;
  (defun LayerTable (/ i a nm l)
    (while (setq i (tblnext "LAYER" (not i)))
      (if (not (wcmatch (setq nm (cdr (assoc 2 i))) "*|*"))
        (setq l (cons (cdr (assoc 2 i)) l))
      )
    )
    (setq l (acad_strlsort l))
  )
  ;; ;;
  (if (ssget "_X" '((0 . "INSERT")))
    (setq run t)
    (alert "No blocks found in this drawing !!")
  )
  (if (and run (setq D (vl-filename-mktemp nil nil ".dcl")) (setq f (open D "w")))
    (progn (write-line
             (strcat
               "test : dialog { label = \"Highlight Blocks\"; width = 46;"
"spacer;"
               ": boxed_column { label = \"Selection Option\";" ": button { label = \"Select Block >>\"; key = \"sbk\";height = 3;}" "spacer;"
               ": popup_list { label = \"Block:\"; key = \"bl\"; width = 42;}"
               ": popup_list { label = \"Layer:\"; key = \"lay\"; width = 42;}}"
"spacer;"
               ": boxed_radio_row { label = \"Selection Way:\"; width = 42;"
               ": radio_button { label = \"Global\"; key = \"g\"; value = \"1\";}"
               ": radio_button { label = \"Window\";key = \"w\";}}"
               ": boxed_row { label = \"Action\"; fixed_width = true; alignment = centered;"
"spacer;"
               ": button { label = \"OK\"; key = \"oki\"; is_default = true; height = 1.75; width = 21;}"
               ": button { label = \"Cancel\"; key = \"esc\"; is_cancel = true; height = 1.75; width = 21;}}}"
              )
             f
           )
           (close f)
    )
  )
  (if (or (not D) (not (new_dialog "test" (setq id (load_dialog D)))))
    (progn (if (> id 0)
             (unload_dialog id)
           )
           (if (and D (setq D (findfile D)))
             (vl-file-delete D)
           )
    )
    (progn
      (setq layers (append (list "-- On Any Layer --") (LayerTable))
            blocks (BlockTable)
      )
      (mapcar '(lambda (k l) (start_list k) (mapcar 'add_list l) (end_list))
              (list "bl" "lay")
              (list blocks layers)
      )
      (if (and *GetBlockName* (tblsearch "BLOCK" *GetBlockName*))
        (set_tile "bl" (itoa (vl-position *GetBlockName* blocks)))
      )
      (action_tile "sbk" "(setq sel t)(done_dialog)")
      (action_tile
        "oki"
        "(setq lst (mapcar 'get_tile (list \"bl\" \"lay\" \"g\" \"w\"))
                                     bn (nth (atoi (car lst)) blocks)
                                     go t *GetBlockName* nil) (done_dialog)"
      )
      (action_tile "esc" "(setq go nil) (done_dialog)")
      (start_dialog)
      (unload_dialog id)
      (vl-file-delete D)
    )
  )
  (if (and sel (princ "\n Pick Block :") (setq s (ssget "_+.:S:E" '((0 . "INSERT")))))
    (progn (setq *GetBlockName* (vla-get-effectivename (vlax-ename->vla-object (ssname s 0))))
           (c:GetBlocks)
    )
  )
  (if (and bn
           go
           (setq ss (ssget (if (eq (caddr lst) "1")
                             "_X"
                             "_:L"
                           )
                           (list '(0 . "INSERT")
                                 (cons 8
                                       (if (eq (cadr lst) "0")
                                         "*"
                                         (nth (atoi (cadr lst)) layers)
                                       )
                                 )
                                 (cons 2 (strcat "`*U*," bn))
                           )
                    )
           )
      )
    (progn (repeat (setq i (sslength ss))
             (if (not (eq (vla-get-effectivename (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))))) bn))
               (ssdel sn ss)
             )
           )
           (sssetfirst nil ss)
    )
  )
  (princ)
)

Anything you have to offer would be greatly appreciated.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #1 on: August 09, 2014, 12:34:13 AM »
That's an odd way to leave the dialog and re-enter.
I'll take a closer look in the morning. 12:30AM here.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dortega4269

  • Guest
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #2 on: August 09, 2014, 12:38:04 AM »
That's an odd way to leave the dialog and re-enter.
I'll take a closer look in the morning. 12:30AM here.
Why thank you CAB. Enjoy your rest ;)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #3 on: August 09, 2014, 10:07:34 AM »
OK not a complete routine but the dialog works to select inserts  and layer list updates.
The global / window thing I did not mess with.
Code: [Select]
(defun c:getblocks (/ *error* d f id run go sel layers blocks s lst ss i sn bn go blocktable layertable blLay)
  ;;    Author: Tharwat Al Shoufi    ;;
  ;;    GetBlocks Program         ;;
  ;;    Date : 04. August. 2014        ;;
  ;;  Modifications by CAB @ TheSwamp 08/09/14
  (defun *error* (msg)
    (if (and d (setq d (findfile d)))
      (vl-file-delete d)
    )
    (if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")
      (princ msg)
      (princ (strcat "\n ** Error : " msg " **"))
    )
  )
  ;;                            ;;
  (defun blocktable (/ i a l nm)
    (while (setq i (tblnext "BLOCK" (not i)))
      (if (not (wcmatch (setq nm (cdr (assoc 2 i))) "`**"))
        (setq l (cons nm l))
      )
    )
    (setq l (acad_strlsort l))
  )
  ;;                            ;;
  (defun layertable (/ i a nm l)
    (while (setq i (tblnext "LAYER" (not i)))
      (if (not (wcmatch (setq nm (cdr (assoc 2 i))) "*|*"))
        (setq l (cons (cdr (assoc 2 i)) l))
      )
    )
    (setq l (acad_strlsort l))
  )


 
  ;;                            ;;
  (defun getInsertLay (bn / ss i ename lay) ; CAB
  (if (setq ss (ssget "_X" (list '(0 . "INSERT")
                                 ;;(cons 8 (if (eq (cadr lst) "0") "*" (nth (atoi (cadr lst)) layers)))
                                 (cons 2 (strcat "`*U*," bn))))
      )
    (progn
      (repeat (setq i (sslength ss)) ; remove una blocks that don't match name
       (if (not (eq (vla-get-effectivename (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))))) bn))
          (ssdel sn ss)
       )
      )
     ;;(sssetfirst nil ss)
     (setq *getblockname* bn)
       (setq i -1)
       (while (setq ename (ssname ss (setq i (1+ i))))
         (setq l (cdr(assoc 8 (entget ename))))
         (if (not (vl-position l lay))
           (setq lay (cons l lay))
         )
       )
    )
  )
    (if lay
      (setq lay (acad_strlsort lay)
            lay (append '("-- On Any Layer --") lay))
    )
  )

  (defun resetlay (bn) ; CAB
    (setq blLays (getInsertLay bn))
    (start_list "lay") (mapcar 'add_list blLays) (end_list)
  )

 
  (defun create_dcl(/ d)       ; CAB moved to a function
     
    (if (and (or (ssget "_X" '((0 . "INSERT")))
                 (alert "No blocks found in this drawing !!"))
             (setq d (vl-filename-mktemp nil nil ".dcl")) (setq f (open d "w")))
      (progn (write-line
               (strcat
                 "tempdcl : dialog { label = \"Highlight Blocks\"; width = 46;" "spacer;"
                 ": boxed_column { label = \"Selection Option\";"
                 ": button { label = \"Select Block >>\"; key = \"sbk\";height = 3;}" "spacer;"
                 ": popup_list { label = \"Block:\"; key = \"bl\"; width = 42;}"
                 ": popup_list { label = \"Layer:\"; key = \"lay\"; width = 42;}}" "spacer;"
                 ": boxed_radio_row { label = \"Selection Way:\"; width = 42;"
                 ": radio_button { label = \"Global\"; key = \"g\"; value = \"1\";}"
                 ": radio_button { label = \"Window\";key = \"w\";}}"
                 ": boxed_row { label = \"Action\"; fixed_width = true; alignment = centered;" "spacer;"
                 ": button { label = \"OK\"; key = \"oki\"; is_default = true; height = 1.75; width = 21;}"
                 ": button { label = \"Cancel\"; key = \"esc\"; is_cancel = true; height = 1.75; width = 21;}}}"
                )
               f
             )
             (close f)
        d
      )
    )
 
  )

  (defun dialog_data()  ; CAB
    (or *layers* (setq *layers* (append '("-- On Any Layer --") (layertable))))
    (setq blLays  *layers*
          blocks (blocktable)
          lst    nil ; reset the lst var
    )
   
    (if (vl-position *getblockname* blocks) ; CAB
        (setq blLays (getInsertLay *getblockname*))
    )
   
    (mapcar '(lambda (k l) (start_list k) (mapcar 'add_list l) (end_list))
            (list "bl" "lay")
            (list blocks blLays) ; CAB
    )
    (if (and *getblockname* (tblsearch "BLOCK" *getblockname*))
      (set_tile "bl" (itoa (vl-position *getblockname* blocks)))
    )
    (action_tile "sbk" "(done_dialog 2)") ; user pick Block & return
    (action_tile "bl" "(setq pkbn (nth (atoi $value) blocks))(resetlay pkbn)")
    (action_tile "oki"
      "(setq lst (mapcar 'get_tile (list \"bl\" \"lay\" \"g\" \"w\"))
             bn (nth (atoi (car lst)) blocks)
             blay (nth (atoi (cadr lst)) blLays)) (done_dialog 1)"
    )
    (action_tile "esc" "(done_dialog 0)") ; bye bye
  )



 
  (defun UserPickBlock (/ s bn)  ; CAB
    (princ "\n Pick Block :")
    (if (and (setq s (ssget "_+.:S:E" '((0 . "INSERT")))) ; single pick insert only
             (setq bn (vla-get-effectivename (vlax-ename->vla-object (ssname s 0)))))
       (setq *getblockname* bn)
    )
    bn
  )


  ;;  All new by CAB
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;                  Run the Dialog
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun doit (dcl_id / x y layouts vlayouts ptr action doc one tmp)

    (dialog_data) ; actions


    ;;  Start Dialog Box
    (setq do_dialog t) ; flag loop to start

    ;;  repeat dialog until user exits
    (while do_dialog
      (if (> (setq action (start_dialog)) 1) ; temp exit of dialog
        (progn
          (cond
            ((= action 2)
             (setq pkbn (UserPickBlock)))
          )
          (new_dialog "tempdcl" dcl_id) ;  restart the dialog box
          (dialog_data)
        )
        ;;  ELSE user wants to quit
        (setq do_dialog nil)
      )
    ) ; endwhile
    (unload_dialog dcl_id)

  ) ; end defun

  ;;  All new by CAB
  ;;================================================================
  ;;                    Start of Routine                           
  ;;================================================================
  (vl-load-com)

 
  (cond
    ((not (setq dclfile (create_dcl))) (prompt (strcat "\nCannot create " dclfile ".")))
    ((< (setq dcl# (load_dialog dclfile)) 0) (prompt (strcat "\nCannot load " dclfile ".")))
    ((not (new_dialog "tempdcl" dcl#)) (prompt (strcat "\nProblem with " dclfile ".")))
    ((doit dcl#)) ; No DCL problems: fire it up
  ) ; end cond
  (if (and dclfile (setq dclfile (findfile dclfile)))
    (vl-file-delete dclfile)
  )
  (if lst ; user said OK & lst holds data needed
    (princ (strcat bn "  " blay))
  )
  (princ)
) ; end defun main

  (princ)
;|«Visual LISP© Format Options»
(120 2 2 2 nil "end of " 100 9 1 1 1 nil T nil T)
;*** DO NOT add text below the comment! ***|;
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dortega4269

  • Guest
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #4 on: August 09, 2014, 11:21:11 AM »
Thank you CAB. When I get a moment I'll load it and let you know how it works. Thanks for your help. I very much appreciate your time and efforts.  :-D

dortega4269

  • Guest
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #5 on: August 09, 2014, 05:40:03 PM »
OK not a complete routine but the dialog works to select inserts  and layer list updates.
The global / window thing I did not mess with.

CAB,
The initial selection and layer filtering works perfectly, however, the blocks do not remain selected based on the Block Name and/or Layer selection.

Any suggestions?

Here's a quick video:
http://youtu.be/dLI6VnhKiA4
« Last Edit: August 09, 2014, 05:44:25 PM by dortega4269 »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #6 on: August 09, 2014, 06:22:10 PM »
Did not realize what your end game was. If I have time tomorrow I'll take another look.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dortega4269

  • Guest
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #7 on: August 10, 2014, 01:23:30 AM »
CAB,
If you read this thread, http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Selection-Set-by-block-name/m-p/5192827#M324878 you will find my requests and the history behind this routine.

If you need anything at all, just ask.  I'm not too savvy with writing routines or the thought process, but I'll try and answer any question to the best of my ability.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #8 on: August 10, 2014, 08:42:57 AM »
OK I see what you are after.
The Global / Current Layout buttons work as expected now.

Code: [Select]
(defun c:getblocks (/ *error* d f id run go sel layers blocks s lst ss i sn bn go blocktable layertable blLay)
  ;;    Author: Tharwat Al Shoufi    ;;
  ;;    GetBlocks Program         ;;
  ;;    Date : 04. August. 2014        ;;
  ;;  Modifications by CAB @ TheSwamp 08/09/14
  (defun *error* (msg)
    (if (and d (setq d (findfile d)))
      (vl-file-delete d)
    )
    (if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")
      (princ msg)
      (princ (strcat "\n ** Error : " msg " **"))
    )
  )
  ;;                            ;;
  (defun blocktable (/ i a l nm)
    (while (setq i (tblnext "BLOCK" (not i)))
      (if (not (wcmatch (setq nm (cdr (assoc 2 i))) "`**"))
        (setq l (cons nm l))
      )
    )
    (setq l (acad_strlsort l))
  )
  ;;                            ;;
  (defun layertable (/ i a nm l)
    (while (setq i (tblnext "LAYER" (not i)))
      (if (not (wcmatch (setq nm (cdr (assoc 2 i))) "*|*"))
        (setq l (cons (cdr (assoc 2 i)) l))
      )
    )
    (setq l (acad_strlsort l))
  )


 
  ;;                            ;;
  (defun getInsertLay (bn / ss i ename lay) ; CAB
  (if (setq ss (ssget "_X" (list '(0 . "INSERT")
                                 ;;(cons 8 (if (eq (cadr lst) "0") "*" (nth (atoi (cadr lst)) layers)))
                                 (cons 2 (strcat "`*U*," bn))))
      )
    (progn
      (repeat (setq i (sslength ss)) ; remove una blocks that don't match name
       (if (not (eq (vla-get-effectivename (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))))) bn))
          (ssdel sn ss)
       )
      )
     ;;(sssetfirst nil ss)
     (setq *getblockname* bn)
       (setq i -1)
       (while (setq ename (ssname ss (setq i (1+ i))))
         (setq l (cdr(assoc 8 (entget ename))))
         (if (not (vl-position l lay))
           (setq lay (cons l lay))
         )
       )
    )
  )
    (if lay
      (setq lay (acad_strlsort lay)
            lay (append '("-- On Any Layer --") lay))
    )
  )

  (defun resetlay (bn) ; CAB
    (setq blLays (getInsertLay bn))
    (start_list "lay") (mapcar 'add_list blLays) (end_list)
  )

 
  (defun create_dcl(/ d)       ; CAB moved to a function
     
    (if (and (or (ssget "_X" '((0 . "INSERT")))
                 (alert "No blocks found in this drawing !!"))
             (setq d (vl-filename-mktemp nil nil ".dcl")) (setq f (open d "w")))
      (progn (write-line
               (strcat
                 "tempdcl : dialog { label = \"Highlight Blocks\"; width = 46;" "spacer;"
                 ": boxed_column { label = \"Selection Option\";"
                 ": button { label = \"Select Block >>\"; key = \"sbk\";height = 3;}" "spacer;"
                 ": popup_list { label = \"Block:\"; key = \"bl\"; width = 42;}"
                 ": popup_list { label = \"Layer:\"; key = \"lay\"; width = 42;}}" "spacer;"
                 ": boxed_radio_row { label = \"Selection Way:\"; width = 42;"
                 ": radio_button { label = \"Global\"; key = \"g\"; value = \"1\";}"
                 ": radio_button { label = \"Current Layout\";key = \"cspace\";}}"
                 ": boxed_row { label = \"Action\"; fixed_width = true; alignment = centered;" "spacer;"
                 ": button { label = \"OK\"; key = \"oki\"; is_default = true; height = 1.75; width = 21;}"
                 ": button { label = \"Cancel\"; key = \"esc\"; is_cancel = true; height = 1.75; width = 21;}}}"
                )
               f
             )
             (close f)
        d
      )
    )
 
  )

  (defun dialog_data()  ; CAB
    (or *layers* (setq *layers* (append '("-- On Any Layer --") (layertable))))
    (setq blLays  *layers*
          blocks (blocktable)
          lst    nil ; reset the lst var
    )
   
    (if (vl-position *getblockname* blocks) ; CAB
        (setq blLays (getInsertLay *getblockname*))
    )
   
    (mapcar '(lambda (k l) (start_list k) (mapcar 'add_list l) (end_list))
            (list "bl" "lay")
            (list blocks blLays) ; CAB
    )
    (if (and *getblockname* (tblsearch "BLOCK" *getblockname*))
      (set_tile "bl" (itoa (vl-position *getblockname* blocks)))
    )
    (set_tile "g" (if GlobalSelect "1" "0"))
    (set_tile "cspace" (if GlobalSelect "0" "1"))
    (action_tile "g" "(setq GlobalSelect (= $value \"1\"))")
    (action_tile "cspace" "(setq GlobalSelect (= $value \"0\"))")
    (action_tile "sbk" "(done_dialog 2)") ; user pick Block & return
    (action_tile "bl" "(setq pkbn (nth (atoi $value) blocks))(resetlay pkbn)")
    (action_tile "oki"
      "(setq lst (mapcar 'get_tile (list \"bl\" \"lay\" \"g\" \"w\"))
             bn (nth (atoi (car lst)) blocks)
             blay (nth (atoi (cadr lst)) blLays)) (done_dialog 1)"
    )
    (action_tile "esc" "(setq lay nil)(done_dialog 0)") ; bye bye
  )

 
  (defun UserPickBlock (/ s bn)  ; CAB
    (princ "\n Pick Block :")
    (if (and (setq s (ssget "_+.:S:E" '((0 . "INSERT")))) ; single pick insert only
             (setq bn (vla-get-effectivename (vlax-ename->vla-object (ssname s 0)))))
       (setq *getblockname* bn)
    )
    bn
  )


  ;;  All new by CAB
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;                  Run the Dialog
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun doit (dcl_id / x y layouts vlayouts ptr action doc one tmp)

    (dialog_data) ; actions


    ;;  Start Dialog Box
    (setq do_dialog t) ; flag loop to start

    ;;  repeat dialog until user exits
    (while do_dialog
      (if (> (setq action (start_dialog)) 1) ; temp exit of dialog
        (progn
          (cond
            ((= action 2)
             (setq pkbn (UserPickBlock)))
          )
          (new_dialog "tempdcl" dcl_id) ;  restart the dialog box
          (dialog_data)
        )
        ;;  ELSE user wants to quit
        (setq do_dialog nil)
      )
    ) ; endwhile
    (unload_dialog dcl_id)

  ) ; end defun

  (defun BlockSS (bn layers / ss)
  (if (setq ss (ssget "_X" (list '(0 . "INSERT")
                                 (cons 8 (if (eq (cadr lst) "0") "*" layers))
                                 (cons 2 (strcat "`*U*," bn))
                                 (cons 410 (if GlobalSelect "*" (getvar "CTAB")))))
      )
    (progn
      (repeat (setq i (sslength ss)) ; remove una blocks that don't match name
       (if (not (eq (vla-get-effectivename (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))))) bn))
          (ssdel sn ss)
       )
      )
     (sssetfirst nil ss)
    )
  )
    (if ss (sslength ss))
)
 
  ;;  All new by CAB
  ;;================================================================
  ;;                    Start of Routine                           
  ;;================================================================
  (vl-load-com)

  ;;  set first run only
  (or *getblockname* (setq GlobalSelect t)) ; select block in drawing, not layout only
 
  (cond
    ((not (setq dclfile (create_dcl))) (prompt (strcat "\nCannot create " dclfile ".")))
    ((< (setq dcl# (load_dialog dclfile)) 0) (prompt (strcat "\nCannot load " dclfile ".")))
    ((not (new_dialog "tempdcl" dcl#)) (prompt (strcat "\nProblem with " dclfile ".")))
    ((doit dcl#)) ; No DCL problems: fire it up
  ) ; end cond
  (if (and dclfile (setq dclfile (findfile dclfile)))
    (vl-file-delete dclfile)
  )
  (if lst ; user said OK & lst holds data needed
    (progn
      (princ (strcat bn "  " blay))
      (princ "\nBlocks selected ")(princ (BlockSS bn blay))
      (if GlobalSelect
        (princ " in entire Drawing.")
        (princ " in this layout.")
      )
    )
  )
  (princ)
) ; end defun main

  (princ)
;|«Visual LISP© Format Options»
(120 2 2 2 nil "end of " 100 9 1 1 1 nil T nil T)
;*** DO NOT add text below the comment! ***|;
« Last Edit: August 10, 2014, 08:45:59 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alloy mold design

  • Mosquito
  • Posts: 8
  • Automotive wheel mold design
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #9 on: August 10, 2014, 09:44:28 AM »
helpful,very good, thank you CAB
m Foshan City, Guangdong Province, China, car wheels mold design

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #10 on: August 10, 2014, 05:19:14 PM »
Glad you like it. I just finish the routine with my style of programing.
Tharwat did much of the work.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dortega4269

  • Guest
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #11 on: August 11, 2014, 10:14:13 AM »
OK I see what you are after.
The Global / Current Layout buttons work as expected now.

Perfect!  Thank you very much CAB, as always, you're a Gentleman and a Scholar. :-D

http://youtu.be/SznxX0d6Pd8

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #12 on: August 11, 2014, 11:32:56 AM »
You're welcome.

Next phase is to allow multiple selections for layers but will likely need to wait till I get back from vacation. 8)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dortega4269

  • Guest
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #13 on: August 11, 2014, 11:45:37 AM »
You're welcome.

Next phase is to allow multiple selections for layers but will likely need to wait till I get back from vacation. 8)

WOW... that sounds like a plan!  Enjoy your vacation... 8-)

dortega4269

  • Guest
Re: Selection Set by Block Name and Filter by Layer Name...
« Reply #14 on: July 01, 2015, 01:09:40 PM »
You're welcome.

Next phase is to allow multiple selections for layers but will likely need to wait till I get back from vacation. 8)

CAB,
Thanks for the help you offered on this LISP, it works great and gets lots of use.
If you have time, do you think you can help me alter it a bit?

I'd like to start with the original LISP, change it's name, and edit a few of it's features.

This is what I'm looking for:
  • Keep the same selection feature
  • List the blocks current Z-Axis Elevation that is re-definable.
  • List the blocks current parameter "Top of Steel".
  • List the blocks current parameter "Strut Elev" or "Conduit Elev".
  • Take Z-Axis elevation and store the difference from '0' elevation (plus or minus)
  • Use difference of Z-Axis and add it to "Top of Steel" & "Strut Elev" or "Conduit Elev" parameters
Reason for all of this is that I have several blocks I've placed at '0' elevation, and based my parameters ("Top of Steel" & "Strut Elev" or "Conduit Elev") of my block based off of '0'.  Now the floors have been depressed (ex: -3'-4" AFF) or raised (ex: +0'-3" AFF) and I need to adjust them accordingly--lower a few blocks -3'-4" and then add the 3'-4" to the "Top of Steel" & "Strut Elev" or "Conduit Elev" parameters after doing the math.  It's quite tedious, but not the end of the world, like always, just trying to make things easier.

Note: I added some screenshots of my parameters if that helps.




Anything helps.