Redefining a Title Block
15 Jul 2016Several years back I found a great write-up on STB plotting. Unfortunately, the bookmark I had was lost after a hard drive crash. I won’t debate the pros and cons here as it has been done numerous times on several web blogs and forums in the past (CADDManager Blog, AUGI, Autodesk, and CADTutor). Anyway, that article prompted me to move my firm to STB plotting.
With that move, I found I needed to update our title block to use the new STB plot styles. As we also insert our title block in each drawing as opposed to creating a reference to it. (There is a debate for that method, too.) It just means I need to update more drawings.
To update the drawings, I worked up a bit of AutoLISP code to query the possible block names that represent our titleblock blocks.
Titleblock Drawing Names
;;_ Define possible titleblock drawing names (exclude the file extension)
(setq lBlocks (list "TTLB-L-MS-11x17" "TTLB-L-MS-18x24"
"TTLB-L-MS-22x34" "TTLB-L-MS-24x36"
"TTLB-L-MS-30x42" "TTLB-P-MS-LEGAL"
)
)
Select allThe list of possible block names will need to be edited in this routine. One will only want to update this list to include each drawing file needed for redefining existing blocks in the current drawing.
Loop Through Inserted Blocks
;;_ Provide list of block names to query
(foreach n lBlocks
(progn
(if (tblsearch "BLOCK" n)
Select allThis foreach loop cycles through the provided list of block names. It then searches the inserted blocks for that name.
Query Plot Style
;;_ If drawing is set as an STB based plotting,
(if (and (= (getvar "PSTYLEMODE") 1)
(findfile (strcat sFolder n "-STB.dwg"))
)
Select allNow that we have determined the block is in the drawing, we move on to check the drawing plotting style. This will determine if a STB based drawing block is used to reinsert the block definition.
We will also want to check if a drawing with a the same filename but with an “-STP” suffix is available. Otherwise, the original filename will be used.
Redefine Titleblock Definition
;|
OP_RedefTitle_1.1.lsp
Version History
1.1 July 15, 2016 Initial Public Release
1.0 2009 Initial Release
Requires predefined list of blocks.
Dependencies: none
Usage: RedefTitle
Arguments: none
Returns: prompt
Copyright © 2005-2016 by Richard Lawrence
Written permission must be obtained to copy, modify, and distribute
this software. Permission to use this software for any purpose and
without fee is hereby granted, provided that the above copyright
notice appears in all copies and that both the copyright notice and
the limited warranty and restricted rights notice below appear in
all supporting documentation.
THIS PROGRAM IS PROVIDED "AS IS" AND WITH ALL FAULTS. ANY IMPLIED
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE ARE
HEREIN DISCLAIMED. THERE IS NO WARRANTY THAT THE OPERATION OF THE
PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE. USAGE OF THIS PROGRAM
IS AT YOUR OWN RISK.
|;
(defun c:redeftitle (/ cmde sFolder lBlocks)
(setq cmde (getvar "cmdecho")
;;_ Assign base folder path for blocks
sFolder "U:\\Sheets\\"
)
(setvar "cmdecho" 0)
;;_ Define possible titleblock drawing names (exclude the file extension)
(setq lBlocks (list "TTLB-L-MS-11x17" "TTLB-L-MS-18x24"
"TTLB-L-MS-22x34" "TTLB-L-MS-24x36"
"TTLB-L-MS-30x42" "TTLB-P-MS-LEGAL"
)
)
;;_ Provide list of block names to query
(foreach n lBlocks
(progn
(if (tblsearch "BLOCK" n)
(progn
;;_ If drawing is set as an STB based plotting,
(if (and (= (getvar "PSTYLEMODE") 1)
(findfile (strcat sFolder n "-STB.dwg"))
)
;;_ then append the STB version of the block,
(command "insert" (strcat n "=" sFolder n "-STB.dwg") nil)
;;_ else use the CTB version.
(command "insert" (strcat n "=" sFolder n) nil)
)
;;_ Synchronize the attributes for this block.
(command "attsync" "n" n)
)
)
)
)
;;_ Reset cmdecho system variable
(setvar "cmdecho" cmde)
(prompt "\nTitleblock redefined. ")
(princ)
)
Select allDownloadThis routine is intended to run once per drawing. It should not hurt to run it multiple times, though.
If you liked this post, you can share it with your followers or follow me on Twitter!