Jump to content
  • 3

Batch Rename enhancements


scottmoore

Question

The Batch Rename feature is nice, but could use some enhancements:

 

- I think the state of the tool should remain when re-opened in a session until changed. It’s tedious to constantly select type and process each time. 
 

- I would really like the type selection to be check marks instead of a drop down, as it is quite possible one might need to change the name of multiple types of objects at the same time. Case in point, I have a specific template that requires up to 20 name changes and each name change applies to a class, sheet layer, saved view and two symbols. Because the state of the tool reverts each time and you can’t select more than on type of item, It’s only useful for the symbols. It’s faster to do everything else manually. It may be faster to rename the symbols manually in fact. 
 

Just my opinion. 

  • Like 2
Link to comment

24 answers to this question

Recommended Posts

  • 0

@Scott Lebsack Unfortunately, any time Vectorworks opens a dialog window, it will block the rest of the program.  This is deep rooted in the coding with how Vectorworks operates and, to my knowledge, there is no instance where a dialog does not block VW until the dialog is closed.  The only way for this to work would be to rebuild the Batch Rename command as a palette similar to the Navigation Palette or Resource Manager, which I don't see happening.

  • Like 2
Link to comment
  • 0

I think the batch Rename feature is great, but was most likely considered as a wishlist item for renaming multiple hierarchy classes at one time.  There is SO much more you could do with it with some presumably simple updates.  Of course, I don't write software so perhaps NOTHING is really all that simple.  

Link to comment
  • 0
7 hours ago, Jesse Cogswell said:

Unfortunately, any time Vectorworks opens a dialog window, it will block the rest of the program.

 

 

My greatest annoyance since I started with VW.

You want to create a new resource, open the dialog, get unsure about proper naming

but have no option to scroll in Navigation palette or such things. So you have to close

the dialog again and start from scratch losing your settings you already done.

 

Bricscad does the same. In C4D or Modo you can open thousands of dialog windows

that stay and wait for your input, move them around but still access the whole GUI.

In C4D you can even start a bunch of Renderings in picture Manager but go back

to your main file and go on working.

  • Like 1
Link to comment
  • 0

@scottmoore Having the Batch Rename command retain previous data would be relatively simple to implement into the existing tool if VW would choose to do it, as it seems like a conscience choice to clear the fields after pressing the "Apply Changes" button, and there are commands built into Vectorworks to temporarily save dialog choices.

 

I'm not sure exactly how selecting multiple categories would work cleanly, however.  I suppose that you could have a checkbox for each category that would add the objects to the List Browser window, but I could see this becoming overwhelming very, very quickly on a complicated drawing with hundreds of symbols and classes.

 

I could write a plug-in that would do exactly that for you, but I'd first have to essentially re-write the existing Batch Rename command to do it, which would be no small task.  While the command seems really simple on the surface, the actual mechanics are very complicated and would be quite tedious to rebuild.  If you wanted it to be slightly simpler, say to only have an option to add a prefix or suffix, that would be much more manageable.

 

I'm not promising anything, mind you, even with a simpler scope this could take up a substantial amount of time to get working properly.

Link to comment
  • 0

@Jesse Cogswell thanks for the input. It might be helpful if you had an understanding of what I am doing. The particular template in question is for creating stage plots for multiple artist festivals and award shows.  The template is set up for 15 artists initially called “Artist 01”, “Artist 02”, etc. for each Artist there is 

 

class “Artist xx”

sheet layer “Artist xx”

saved view “working - Artist xx”

saved view “print - Artist xx”

symbol “Artist xx keyboards” and a symbol

“Artist xx drums”

 

If I could select class, sheet layer, saved view, and symbol, I could update the file in a couple of minutes. Currently it’s mostly useless for this purpose and the process is pretty tedious. I think the check scenario like one uses with “Number Fixtures” in Spotlight would be ideal in my opinion. 

Edited by scottmoore
  • Like 1
Link to comment
  • 0

So what you really want is a way to change every instance of "Artist xx" to "Scatman John" or some other real artist name?

 

Try the following script.

From the Resource Manager New Resource, Script. Name the Palette what ever you want. Name the script "RenameAll" or whatever you want.

Paste all of the contents from the below code block into the script editor. Make sure the Language pull down at the top is set to Vectorscript. Click OK.

 

Double click on the script name in the palette to run the script. In the first dialog box enter the EXACT string that you want to replace. In the second dialog box enter the string you want to replace it with. All of the objects in the drawing that use the first substring as part of the name should now use the second substring instead. It appears that the changes in names to not effect the Layer or Class visibilities in viewports.

 

Keep your fingers crossed, test thoroughly before using for production.

 

Ski-Ba-Bop-Ba-Dop-Bop

 

Ask again if you need more help.

 

Procedure RenameAll;
{May 4, 2022}
{©2022 Patrick Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{No Warranty Expressed of Implied. Use at your own risk.}

{Walks the Name List of a VW file and finds all occurances}
{of the string entered in the first dialog box and replaces}
{each instance with the string entered in the second dialog}
{box.  }
{Then does the same for the LayerList}

{Lightly tested. Ensure suitability for use before using}
{on production data. Use only with a doctors recommendation.}
{Discontinue use if pain, fever or excessive hair loss occur.}

Var
	OldStr, NewStr, S1, S2		:String;
	L1							:LongInt;
	N1, N2						:Integer;
	H1, H2						:Handle;
	
Begin
	OldStr := StrDialog('Enter substring to find', 'Artist xx');
	NewStr := StrDialog('Enter subtring to replace with', 'Scatman John');
	For L1 := 1 to NameNum DO
		BEGIN
			S1 := NameList(L1);
			N1 := Pos(OldStr, S1);
			If N1<>0 THEN
				BEGIN
					H1:=GetObject(S1);				
					Delete(S1, N1, Len(OldStr));
					Insert(NewStr, S1, N1);
					SetName(H1, S1);
				End;
			H2:=Flayer;
			While H2 <> Nil DO
				BEGIN
					S2:=GetLName(H2);
					N2:=Pos(OldStr, S2);
					If N2<>0 THEN
						BEGIN
							Delete(S2, N2, Len(OldStr));
							Insert(NewStr, S2, N2);
							SetName(H2, S2);
						End;
					H2:=NextLayer(H2);
				End;
		End;
End;

Run(RenameAll);

 

  • Like 2
Link to comment
  • 0
13 hours ago, Pat Stanford said:

So what you really want is a way to change every instance of "Artist xx" to "Scatman John" or some other real artist name?

 

Try the following script.

From the Resource Manager New Resource, Script. Name the Palette what ever you want. Name the script "RenameAll" or whatever you want.

Paste all of the contents from the below code block into the script editor. Make sure the Language pull down at the top is set to Vectorscript. Click OK.

 

Double click on the script name in the palette to run the script. In the first dialog box enter the EXACT string that you want to replace. In the second dialog box enter the string you want to replace it with. All of the objects in the drawing that use the first substring as part of the name should now use the second substring instead. It appears that the changes in names to not effect the Layer or Class visibilities in viewports.

 

Keep your fingers crossed, test thoroughly before using for production.

 

Ski-Ba-Bop-Ba-Dop-Bop

 

Ask again if you need more help.

 

Procedure RenameAll;
{May 4, 2022}
{©2022 Patrick Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{No Warranty Expressed of Implied. Use at your own risk.}

{Walks the Name List of a VW file and finds all occurances}
{of the string entered in the first dialog box and replaces}
{each instance with the string entered in the second dialog}
{box.  }
{Then does the same for the LayerList}

{Lightly tested. Ensure suitability for use before using}
{on production data. Use only with a doctors recommendation.}
{Discontinue use if pain, fever or excessive hair loss occur.}

Var
	OldStr, NewStr, S1, S2		:String;
	L1							:LongInt;
	N1, N2						:Integer;
	H1, H2						:Handle;
	
Begin
	OldStr := StrDialog('Enter substring to find', 'Artist xx');
	NewStr := StrDialog('Enter subtring to replace with', 'Scatman John');
	For L1 := 1 to NameNum DO
		BEGIN
			S1 := NameList(L1);
			N1 := Pos(OldStr, S1);
			If N1<>0 THEN
				BEGIN
					H1:=GetObject(S1);				
					Delete(S1, N1, Len(OldStr));
					Insert(NewStr, S1, N1);
					SetName(H1, S1);
				End;
			H2:=Flayer;
			While H2 <> Nil DO
				BEGIN
					S2:=GetLName(H2);
					N2:=Pos(OldStr, S2);
					If N2<>0 THEN
						BEGIN
							Delete(S2, N2, Len(OldStr));
							Insert(NewStr, S2, N2);
							SetName(H2, S2);
						End;
					H2:=NextLayer(H2);
				End;
		End;
End;

Run(RenameAll);

 

@Pat StanfordSuper thanks, you've created a tool I have wished for for some time. Gonna give it a whirl shortly as I have need at this moment of it — how massively timely! (Also a shoutout to @scott moore for getting the ball rolling here).

Not to pile on, but any chance it could be made to act on "Selected Only"? 

How many times have I upcycled a VWX doc from previous to current event, albeit with all-new dances, acts etc. (the actual answer: too many to count)

However, many's the time a global change would affect more items than needed, so a by-selection à la the Text menus's "Find and Replace…" would be super useful.

Link to comment
  • 0
23 minutes ago, mjm said:

However, many's the time a global change would affect more items than needed, so a by-selection à la the Text menus's "Find and Replace…" would be super useful.

This script does not even look at the objects, it only looks at the name lists.

 

If you don't care about Classes, Saved Views, Layers and other things that are not objects in the drawing, then a version that would change a portion of the name like above of selected objects is certainly possible.

 

If you really want this, think through exactly what you want so I am no playing whack a mole with every version triggering an "oh it would be good if it would do XXX also". 😉

Link to comment
  • 0
Just now, Pat Stanford said:

This script does not even look at the objects, it only looks at the name lists.

 

If you don't care about Classes, Saved Views, Layers and other things that are not objects in the drawing, then a version that would change a portion of the name like above of selected objects is certainly possible.

 

If you really want this, think through exactly what you want so I am no playing whack a mole with every version triggering an "oh it would be good if it would do XXX also". 😉

Hello @Pat Stanford thank you for the consideration. I'll give your current script a whirl and then reply back with a more thought-thru request. Much obliged

Link to comment
  • 0
19 hours ago, Pat Stanford said:

@Jesse Cogswell  Show off 😉

 

Very nice work. I wish I was willing to learn to do reasonable dialog boxes.  😂

As one who can barely type, much less program, it's literally a thrill here on the sidelines watching you folks build these incredibly useful mini-machines of code

 

Thanks to you all

Link to comment
  • 0
On 5/4/2022 at 5:13 AM, scottmoore said:

The Batch Rename feature is nice, but could use some enhancements:

 

- I think the state of the tool should remain when re-opened in a session until changed. It’s tedious to constantly select type and process each time. 
 

- I would really like the type selection to be check marks instead of a drop down, as it is quite possible one might need to change the name of multiple types of objects at the same time. Case in point, I have a specific template that requires up to 20 name changes and each name change applies to a class, sheet layer, saved view and two symbols. Because the state of the tool reverts each time and you can’t select more than on type of item, It’s only useful for the symbols. It’s faster to do everything else manually. It may be faster to rename the symbols manually in fact. 
 

Just my opinion. 


Yes and I'd like to add on a request for All on or All off toggle for check marks. I find it it is hard to select all rows and deselect at the beginning when the box opens... something about it feels awkward ui wise.

thanks!

Link to comment
  • 0
On 5/8/2022 at 4:02 AM, Jesse Cogswell said:

@scottmoore After some noodling around this weekend, this is what I came up with.  This menu command launches a dialog box.  As you type in the Text field, the list browser becomes populated with objects whose names contain the given text, sorted by object type and defaulting to being selected.  As you type in the Replace With field, the Result column of the list browser will show you what the resulting rename will be, highlighting in red if a matching object name already exists in the drawing.

 

The search text is not case sensitive since Vectorworks names are also not case sensitive.  However, this also means that this tool cannot be used for changing an object's name casing, since it will be flagged as an existing object name.  If changing an object's name will create a conflict as a result of this tool, an alert dialog will appear to notify you, but the operation will still go through for any objects without a conflict.

 

I should mention that any interaction with the Text field will reset the Replace With field as well as the list browser.

 

image.png.0886485a191f58bf471adb998a04caba.png

 

The tool will work on any version of Vectorworks from 2019 forward.  To install the plug-in, follow the steps below:

 

  1. Download attached .vsm file.
  2. Open up your User Folder in an Explorer/Finder window.  The easiest way I've found to get to it if you don't already know where to look is to go to Vectorworks Preferences, click on the User Folders tab, then click on the Explore / Open in Finder button.
  3. Place the .vsm file you downloaded into the Plug-ins folder.
  4. Restart Vectorworks.
  5. Go to Tools - Workspaces - Edit Current Workspace.
  6. Click on the Menus tab.
  7. In the box on the left, find and expand the JNC category.
  8. In the box on the right, identify a menu to place the tool.
  9. Click and drag Replace Name Text from the box on the left to the target menu on the right.
  10. Click OK.

This was a fun little project and I've already started making use of the tool in my own workflow.  I primarily drive VW2019 which predates the Batch Rename menu command, and this can be used to rename many things really quickly.

Replace Name Text.vsm 13.34 kB · 5 downloads

OK, this is really quite amazing and I really appreciate it.  I do have one question; the script does not seem to locate sheet layers.  Any suggestions?  Otherwise, this is exactly what I needed and a massive time saver.  It finds layers, classes, saved views, and symbols in one operation.  So great!! 

 

 

  • Like 1
Link to comment
  • 0

The issue with Sheet Layers is that the actual name of a sheet layer is the sheet number.  The sheet title is an object variable called "layer description."  It would take a bit of retooling to include them, but it's not impossible.  I would also have to write in a bunch of exceptions since you can have more than one sheet layer with the same sheet title since it's not the universal resource name.

 

What would probably be better would be to write an additional script to just handle sheet titles, which would be pretty simple as far as scripts go.

Edited by Jesse Cogswell
Link to comment
  • 0

Copy that and thanks Jesse.  That makes perfect sense.  No need for the additional script as it would take the same amount of time to just rename the sheet layers.  It is interesting to see how all this works.  I've noticed that there must be something to changing the name of a symbol as the name in the resource manager comes up with the newly assigned name.  The symbol's name in the object info seems to remain the original. Regardless, this is a serious game changer and time saver.  I love it!!   

Link to comment
  • 0

@scottmoore Good catch with symbols.  I added a line to reset symbols matching the new name.  It should work with embedded symbols and symbols in groups and such. 

 

In testing, I did find a couple of potential dangers of this tool, mainly with renaming symbol definitions that are being used inside plug-in objects, as renaming the symbol won't pass the new name in to the PIOs.  It's nothing outside behavior similar to renaming a symbol through the Resource Manager, but it is something you need to keep in mind.

 

I also discovered a bug with renaming Resource Manager folders with this tool (at least in VW2019).  If you use the tool and rename a Resource Manager folder, the Resource Manager will reflect the change, but the tree control in the left pane of the Resource Manager will not, and you will be unable to open the folder or get to the resources inside it.  So the tool will no longer be able to rename Resource Manager folders.

Replace Name Text.vsm

Link to comment
  • 0

Hello @Jesse Cogswell,

Great thanks for all your amazing work you freely share with community.

All these wonderful tools cant be for free.

Please send me DM message with your paypal acount ;-)

 

Anyway, one question regarding Replace Name Text plugin is Error Message I get.

Any idea what might be the issue?

It works fine in blank file, not in any other based on my template file with many folders with resources....

 

Thanks.

 

 

992119630_Snmkaobrazovky2022-06-17o12_21_09.thumb.png.1277913ffb8cb06351c079398f357a4f.png

Link to comment
  • 0

To anyone who uses the Replace Name Text tool that I posted above, I have a new version that fixes a few bugs and adds a couple of features.

  • Fixed a bug resulting from unknown object types not found in the Function Reference
  • Added a checkbox to limit name replacement for only selected objects (helpful when renaming Viewports)
  • Allows for leaving the Replace With field empty, letting the user remove text

Please let me know if anything breaks or doesn't work as intended.  Installation will be the same as listed above.

Replace Name Text.vsm

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...