renaming individual blocks used in larger block assemblies possible?

renaming individual blocks used in larger block assemblies possible?

Anonymous
Not applicable
521 Views
5 Replies
Message 1 of 6

renaming individual blocks used in larger block assemblies possible?

Anonymous
Not applicable
I created some simple line based objects and created blocks out of them with WBLOCK. The name scheme was 1.2m.pipe.pipex, 3.0m.right.angle.pipex (pipex suffix). I then used these individual component blocks to assemble some prefabricated larger assemblies such as Mezzanine.1.2x1.2m I later created 3D versions of the same individual components and WBLOCKED and named them them with the same suffix. At the same time I re WBLOCKED the original simple line based objects but this time named them 1.2.pipe.trueflex, 3.0m.right.angle.trueflex (trueflex suffix). Now when inserting either of the 3D blocks (pipex suffix) and the reblocked/renamed line based objects (trueflex suffix) from the tool palettes in a drawing there are no problems since the naming scheme for all are unique to each block. However, when I insert the prefabricated assembly blocks which were created with the original line based objects with the pipex suffix, I now have an issue where, once exploded, I then insert the 3D blocks of the same type, they are inserted as the line based objects that made up the assembly and not the true 3D objects that they now are which occupy the the same original name scheme. Unforeseen planning on my behalf. Other than recreating all the assemblies with the newly named line based objects (also want to do versions with the 3D blocks) is there a quick and dirty method to work around this conflicting scenario? I'm not sure REDEFINE or REFEDIT are suited to this. Is there a possibility to select inserted assembly block without exploding and obtain a list of all the individual block names and change and replace the suffix from pipex to trueflex? Ideas appreciated.
0 Likes
Accepted solutions (1)
522 Views
5 Replies
Replies (5)
Message 2 of 6

h_s_walker
Mentor
Mentor

@Anonymous wrote:
I created some simple line based objects and created blocks out of them with WBLOCK. The name scheme was 1.2m.pipe.pipex, 3.0m.right.angle.pipex (pipex suffix).
I then used these individual component blocks to assemble some prefabricated larger assemblies such as Mezzanine.1.2x1.2m I later created 3D versions of the same individual components and WBLOCKED and named them them with the same suffix.
At the same time I re WBLOCKED the original simple line based objects but this time named them 1.2.pipe.trueflex, 3.0m.right.angle.trueflex (trueflex suffix). Now when inserting either of the 3D blocks (pipex suffix) and the reblocked/renamed line based objects (trueflex suffix) from the tool palettes in a drawing there are no problems since the naming scheme for all are unique to each block.
However, when I insert the prefabricated assembly blocks which were created with the original line based objects with the pipex suffix, I now have an issue where, once exploded, I then insert the 3D blocks of the same type, they are inserted as the line based objects that made up the assembly and not the true 3D objects that they now are which occupy the the same original name scheme.
Unforeseen planning on my behalf. Other than recreating all the assemblies with the newly named line based objects (also want to do versions with the 3D blocks) is there a quick and dirty method to work around this conflicting scenario?
I'm not sure REDEFINE or REFEDIT are suited to this. Is there a possibility to select inserted assembly block without exploding and obtain a list of all the individual block names and change and replace the suffix from pipex to trueflex? Ideas appreciated.

No ideas, but please use paragraphs. Walls of text are a pain to read

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 3 of 6

Anonymous
Not applicable
Haha love it 😉 Write up message in plain text editor (paragraphed), paste in text field of forum, no change in formatting seen, hit post, close browser, see ya later. In comes reply, calling me up on a walls of text. Isn't the first time this forum makes a mess of peoples' postings.
0 Likes
Message 4 of 6

Anonymous
Not applicable
(defun C:BNM- (/ blist bl b find replace FindList Replacelist  NewName)
(defun _match (b l)
       (vl-every '(lambda (k)
          (wcmatch (strcase b) (strcat "*" k "*")))  l
                                        )
  )
  (setq blist '()
        bl nil
  FindList nil
  Replacelist nil)
  (while  (and
		  (setq find (Strcase (getstring "\nString to Find/Press Enter for none: ")))
		  (not (eq "" find))
		  (setq FindList (cons find FindList))
		  (setq replace (Strcase (getstring (strcat "\nReplace " find " with: ")))
		  (not (eq "" replace))
		  (setq replaceList (cons replace replaceList))
		  	)
		  )
  (if (and FindList
      (progn
	  (while (setq bl (tblnext "block" (not bl)))
	    (and (zerop (logand 53 (cdr (assoc 70 bl))))
		 (_match (setq bl (cdr (assoc 2 bl))) FindList)
	         (or (member bl blist) (setq blist (cons bl blist)))
	    )
	  ) blist))
	  (foreach itm blist
	    (setq Newname itm)
	    (mapcar '(lambda (x y / p)
		(setq p (vl-string-search x (strcase itm))
	    	      Newname	(strcat (strcat (substr Newname 1 p) y 
	    			(substr Newname (+ p (strlen x) 1))))))
		   findlist Replacelist)
	    (command "_rename" "_b" itm NewName)
	  )
  )
  (print (length blist))(princ " Blocks Renamed")
  (princ)
)
0 Likes
Message 5 of 6

Anonymous
Not applicable
Accepted solution

Try again since it time out and wouldn't let me edit.

 

Lisp Routine to find and replace text in block names Courtesy of 'pbejse'

 

(defun C:BNM- (/ blist bl b find replace FindList Replacelist  NewName)
(defun _match (b l)
       (vl-every '(lambda (k)
          (wcmatch (strcase b) (strcat "*" k "*")))  l
                                        )
  )
  (setq blist '()
        bl nil
  FindList nil
  Replacelist nil)
  (while  (and
		  (setq find (Strcase (getstring "\nString to Find/Press Enter for none: ")))
		  (not (eq "" find))
		  (setq FindList (cons find FindList))
		  (setq replace (Strcase (getstring (strcat "\nReplace " find " with: ")))
		  (not (eq "" replace))
		  (setq replaceList (cons replace replaceList))
		  	)
		  )
  (if (and FindList
      (progn
	  (while (setq bl (tblnext "block" (not bl)))
	    (and (zerop (logand 53 (cdr (assoc 70 bl))))
		 (_match (setq bl (cdr (assoc 2 bl))) FindList)
	         (or (member bl blist) (setq blist (cons bl blist)))
	    )
	  ) blist))
	  (foreach itm blist
	    (setq Newname itm)
	    (mapcar '(lambda (x y / p)
		(setq p (vl-string-search x (strcase itm))
	    	      Newname	(strcat (strcat (substr Newname 1 p) y 
	    			(substr Newname (+ p (strlen x) 1))))))
		   findlist Replacelist)
	    (command "_rename" "_b" itm NewName)
	  )
  )
  (print (length blist))(princ " Blocks Renamed")
  (princ)
)
0 Likes
Message 6 of 6

3wood
Advisor
Advisor

To find and replace a certain text string in block names, simply use command RENAME, use wild card to find and rename multiple blocks.
*.pipex  -->  *.trueflex

You can also try command BLOCKUPDATE in attached vlx file. It asks for a block library directory and then replaces blocks in current drawing with same-named blocks in the block library directory. In your case, you can still keep "pipes" suffix of 2d blocks but replace them with same-named 3d blocks in a selected folder.

0 Likes