When I export from Revit I end up with a lot of the same blocks
Linear Supply Diffuser - 4ft length - V223-M101
Linear Supply Diffuser - 4ft length - V421-M101
Linear Supply Diffuser - 4ft length - V151-M101
Linear Supply Diffuser - 4ft length - V631-M101
Round Duct Takeoff - Conical - Standard-V250-M101
Round Duct Takeoff - Conical - Standard-V60-M101
Is there a routine/script that will do a block search for *Linear Supply* , if that block exist, then take the first instance and replace all remaining blocks that contain *Linear Supply* with the first block instance it found. I would end up with 1 block called "Round Duct Takeoff - Conical".
I know it seems like a bit much but I cant figure out another way to tackle this. The real problem is after export there are hundreds of Blocks all mostly the same. The client does not want 30 instances of the same block in a drawing.
Thanks
@dglenn9000 wrote:
....Is there a routine/script that will do a block search for *Linear Supply* , if that block exist, then take the first instance and replace all remaining blocks that contain *Linear Supply* with the first block instance it found. ....
There may not be one, but there certainly could be.... I would add the renaming of that first-found Block name to whatever the common name content is alone, omitting all the part number stuff or whatever the rest of it is, so that all such Blocks in your example would end up named "Linear Supply" rather than something like "Linear Supply Diffuser - 4ft length - V223-M101" even though much of that won't be appropriate to many of them. Try something like [untested]:
(vl-load-com)
(setq
name (getstring "\nPartial Block name to become name of all Blocks whose names contain it: ")
ss (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "*" name "*")))); all such Blocks/Minserts
); setq
(if ss ; found some?
(progn ; then
(command
"_.rename" "_block"
(vla-get-Name (vlax-ename->vla-object (ssname ss 0))); name of first such Block
name ; reduce to common content only
); command
(foreach blk (mapcar 'cadr (ssnamex ss)); convert to list of entity names
(vla-put-Name (vlax-ename->vla-object blk) name)
); foreach
); progn
(prompt "\nNo such Blocks found."); else
); if
That assumes that all such Blocks have their drawn content in the same positional and rotational and size relationship to their insertion points. If not, some of the insertions will move or rotate or scale differently when the new Block name is assigned to them.
Doesn't yet account for locked Layer(s), have error handling, disallow Xrefs [if any might have such names], etc., etc., but that can all be added easily enough, if the concept works for you.