Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Active Contributor
Posts: 48
Registered: ‎01-15-2009
Message 1 of 2 (619 Views)
Accepted Solution

TBLSEARCH in current tab

619 Views, 1 Replies
07-06-2011 08:29 AM

Is it possible to tblsearch only in the current tab?  I have a routine that queries the table and if it finds a certain block within a Xref it inserts the appropiate block.  The problem is that sometimes I have different XREFs in the same DWG but on seperate tabs.. I'd love to only search the current tab.


as it is right now



       ((tblsearch "block" "xref_tblk|8x11")
    (setq bl01 "Titleblocks/8.5x11_info.dwg")
       );cond - 8.5x11
       ((tblsearch "block" "Xref_Tblk-8.5x11|8x11")
    (setq bl01 "Titleblocks/8.5x11_info.dwg")
       );cond - 8.5x11-ASI
       ((tblsearch "block" "xref_tblk|11x17")
    (setq bl01 "Titleblocks/11x17_info.dwg")
       );cond - 11x17

              ((tblsearch "block" "xref_tblk-11x17|11x17")
    (setq bl01 "Titleblocks/11x17_info.dwg")
       );cond - 11x17-ASI
       ((tblsearch "block" "xref_tblk|24x36")
    (setq bl01 "Titleblocks/24x36_info.dwg")
       );cond - 24x36

       ((tblsearch "block" "xref_tblk|30x42")
    (setq bl01 "Titleblocks/30x42_info.dwg")
       );cond - 30x42

       ((tblsearch "block" "xref_tblk|36x48")
    (setq bl01 "Titleblocks/36x48_info.dwg")
       );cond - 36x48


Distinguished Mentor
Posts: 745
Registered: ‎09-14-2003
Message 2 of 2 (612 Views)

Re: TBLSEARCH in current tab

07-06-2011 10:56 AM in reply to: magnar



(tblsearch) only searches for a block definition in the block see if a block reference is inserted in layout tab you should use the (ssget) function but (ssget) can not find xref depended  block reference so what you should do is loop through layout list and for each layout search for xref reference and if it found? insert the right title block


take a look at this:


(defun insert_title_blocks (/ layout xrefName titleBlockName ss)

 (setvar "expert" 1)
 (foreach layout (layoutlist)
  (setvar "ctab" layout)

   '(lambda (xrefName titleBlockName)
     (if (setq ss (ssget (list (cons 0 (strcase xrefName)))))
       (command "._insert" titleBlockName pause pause pause pause ;| here you have to take care of attributes values |;)
                                                  		  ;| if they are exist |;
       (setq ss nil)
       t ; return true 
     ); if
    ); lambda
    (list "Xref_Tblk-8.5x11"        "xref_tblk-11x17"        "xref_tblk-24x36"        "xref_tblk-30x42"        "xref_tblk-36x48"); xref
    (list "Titleblocks/8.5x11_info" "Titleblocks/11x17_info" "Titleblocks/24x36_info" "Titleblocks/30x42_info" "Titleblocks/36x48_info"); title blocks
  ); vl-some
 ); foreach

 (setvar "expert" 0)


i did not test it.







Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.