Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

TBLSEARCH in current tab

668 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

 

..........
     (cond

       ((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

.......

hi,

 

(tblsearch) only searches for a block definition in the block table...to 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)
(vl-some
'(lambda (xrefName titleBlockName)
(if (setq ss (ssget (list (cons 0 (strcase xrefName)))))
(progn
(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.

 

cheers

moshe

 

 

 

Distinguished Mentor
Moshe-A
Posts: 829
Registered: ‎09-14-2003
Message 2 of 2 (661 Views)

Re: TBLSEARCH in current tab

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

hi,

 

(tblsearch) only searches for a block definition in the block table...to 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)

  (vl-some
   '(lambda (xrefName titleBlockName)
     (if (setq ss (ssget (list (cons 0 (strcase xrefName)))))
      (progn
       (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.

 

cheers

moshe

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.