Welcome to WSL!

Make yourself at home, but before posting, please may I ask you to read the following topics.


Posting 101
Server space, screenshots, and you

Thank you!

PS. please pretty please:


Image

[Script] Change Strings - Batch change Names, Expressions, Filepaths

User avatar
UserNoah
Posts: 37
Joined: Mon Mar 09, 2020 11:43 am
Been thanked: 2 times
Contact:

[Script] Change Strings - Batch change Names, Expressions, Filepaths

#1

Post by UserNoah » Tue Jun 30, 2020 7:36 am

Hello everyone,

I have recently started to teach myself scripting. I have never before done anything remotely connected to scripting or coding, besides a little @N = -@N of VEX in Houdini. But I am always impressed with what people on this Forum have created as Scripts and Fuses.
And finally, I had a reason to create one myself.
I needed a proper batch name changer and haven't found one anywhere, so this was a great first script. I got carried away pretty quickly and added more and more features for all kinds of use cases and possible user inputs. Looking back at it, I would've been faster to manually change the names of the dozens of nodes but this was a very good exercise, and surprisingly fun.
I've looked at other scripts that do similar things but often their methods didn't really take into consideration the kind of things I wanted my script to do. Nevertheless, they were extremely helpful. Especially Change Paths and all the UI Examples.

It took me around two weeks to come up with what it is now, I've tried to create the UI in a way that is (hopefully) self-explanatory and to make the search and replace operation as robust as I could.

2020-06-29 14_51_19-Change Strings.jpg

It's not in any way groundbreaking but there are a few things I'm kinda proud of. Like the possibility to search for several patterns in the same session and the fact that it keeps capital letters even if you don't search in case sensitive mode.

I would love to hear if this script works for you, I myself have only tested this in F16 yet, but there is no reason why it shouldn't run in F9.
Unfortunately, it doesn't work in Resolve because it can't access the bmd.scriptlib and even after pasting the functions into the script, it doesn't seem to work because it can't find the "trim" variable. Does anyone have an idea on how to fix this? I've noticed this is the same reason why "Change Paths" doesn't work in Resolve.

There are a few other things I want to change (besides cleaning up the code, it's messy and I stopped making explanatory comments halfway through.)
Like turning the actual search and replace operation into a function so I don't have to change it six times if I want to change the way it works. But I haven't really figured out how to, yet. And I definitely want to add a Quick Selection feature because the script works on selected nodes.

I also realized that if you give the ability of user input (even if it's just you yourself) A LOT of things have to be considered so it doesn't break all the time. This is also the reason why I created a manual detailing the whole script so everyone can use it to it's full potential and know its limitations.
https://noahhaehnel.com/blog/manual-changestrings/

But generally, I was surprised of how well this worked out. Of course, there are a ton of ways to break this script and a lot of redundant lines of code, but I did not expect to create something that works so well without any prior experience. Lua seems to be a very beginner-friendly language and of course this wouldn't have been possible without the countless great Forum posts on here so:

HUGE THANK YOU to everyone that posts on this Forum. Especially Andrews creating GUI posts: viewtopic.php?f=6&t=1411

You can download it here from my DropBox https://www.dropbox.com/s/vmsb7poo3c1to ... s.lua?dl=0
You can also just look at the code through this link.

Let me know if this helps/works for you. If yes, then I could submit it to Reactor for easier installation and updating.
And I'm happy for all the suggestions and tips you have.
You do not have the required permissions to view the files attached to this post.
Last edited by UserNoah on Tue Jun 30, 2020 9:02 am, edited 1 time in total.

User avatar
Midgardsormr
Fusionator
Posts: 1811
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 15
Location: Los Angeles, CA, USA
Been thanked: 106 times
Contact:

Re: Change Strings - Batch change Names, Expressions, Filepaths

#2

Post by Midgardsormr » Tue Jun 30, 2020 8:09 am

The trouble is the namespace. Since Resolve doesn't load the scriptlib, the table bmd is not defined, and you can't add something to the table if that table doesn't exist. In a Console, try transform.x = 5. You'll get an error that there is no such table; same thing is happening in Resolve. If you instead do this:
transform = {}
transform.x = 5

it will work because you've created the table before attempting to create a key in it.

Remove the bmd. from the function declaration and the calls, and make sure the funtion declaration happens near the top, before anything that would call it, and it should work. You might alternately attempt to define the bmd namespace, as in line 13 of the scriptlib, but it's probably not a good idea. Could have unforeseen consequences.

Great work! Quite sophisticated for your first script, too! Storing the preferences and a debugging mode are the kinds of things that I definitely don't expect to see in a first script.

User avatar
UserNoah
Posts: 37
Joined: Mon Mar 09, 2020 11:43 am
Been thanked: 2 times
Contact:

Re: [Script] Change Strings - Batch change Names, Expressions, Filepaths

#3

Post by UserNoah » Tue Jun 30, 2020 8:28 am

Thank you so much Bryan. Your compliment means the world to me. It always feels like I'm talking to a celebrity when I see your username. :D

Your solution to the resolve issue makes sense. I will implement it soon. I was so devasted when I realized it doesn't work in Resolve after I've put so much brain computing time into it.

Regarding the saving of the settings, that actually took me a whole day to figure out. And there are definitely some redundant "if OldData" but I was getting paranoid because often it wouldn't show the inputs you've made in the about window until I let it triple check each time you open and close it.

User avatar
UserNoah
Posts: 37
Joined: Mon Mar 09, 2020 11:43 am
Been thanked: 2 times
Contact:

Re: [Script] Change Strings - Batch change Names, Expressions, Filepaths

#4

Post by UserNoah » Wed Jul 01, 2020 7:53 am

I have updated the script to work in Resolve it can be downloaded here:
https://noahhaehnel.com/blog/manual-changestrings/2/
or here:
https://www.dropbox.com/s/7gimxmd4oru2k ... s.lua?dl=0

Big thanks to you Bryan! I didn't think it could be that easy :D
I wanted to link to your website in the changelog, but am hesitant because it isn't https yet (and does have comments). If I'm not mistaken, the GDPR makes me responsible for websites that I link to. Should I put your Twitter link behind your name?

In "Resolve mode" it will save the Inputs into the global preferences, not sure if I can save it in the Project settings. I guess I will look at this at some point.
But the upside to this is, that if you run the Script in Fusion Standalone, you can now decide if you want to save the Inputs locally into the comp file or globally into the Fusion preferences.


There is a changelog on the website as well, but just for ease of access:
  • Change Strings now supports DaVinci Resolve’s Fusion Page
  • It automatically detects if it was opened in Fusion Standalone or DaVinci Resolve and changes its behavior to properly work in the corresponding software.
  • Added the possibility to save the Inputs globally (Fusion Standalone only)
  • Added a new “?” for this new setting
  • Updated the manual accordingly
  • Fixed a bug that prevented the Script to work when more Search for Inputs than Replace with Inputs were available
I obviously tested this in Resolve and also in Fusion 9, now. Everything seems to be working. It would still be great (if somebody tested it, yet) to tell me if it works for you. :lol:

User avatar
Midgardsormr
Fusionator
Posts: 1811
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 15
Location: Los Angeles, CA, USA
Been thanked: 106 times
Contact:

Re: [Script] Change Strings - Batch change Names, Expressions, Filepaths

#5

Post by Midgardsormr » Wed Jul 01, 2020 8:35 am

Yeah... I haven't bothered with SSL because it's a hassle that requires actual human intervention instead of being automated like everything else with my host. Plus it will almost double my hosting expenses. And I'm not actually collecting any real data. I don't actually care who comments, or if their identity is false, so encrypting it seems like a waste of resources.

I guess I should do something about it, though, if only to preserve my Google ranking. Yeah, the Twitter handle is fine. That'll at least be an indirect link to my site. @Midgaard77

User avatar
UserNoah
Posts: 37
Joined: Mon Mar 09, 2020 11:43 am
Been thanked: 2 times
Contact:

Re: [Script] Change Strings - Batch change Names, Expressions, Filepaths

#6

Post by UserNoah » Mon Jul 06, 2020 8:53 am

I kept obsessing about the user experience of Change Strings over the weekend. Which is why there is a new and vastly improved version available.
The biggest underlying change was to consolidate the different search and replace operations into a single function. This allowed me to add new features insanely fast and keep it much more organized.
Including support for Modifiers took probably the longest to figure out as I first had to find out about the GetTool() command :ugeek: . But eventually, I got it in :lol:

The changes were made pretty much in a single day and today I fixed some "bugs" which more or less only happen due to Lua's search shortcodes.

Other than that, it's pretty much everything I wanted it to be.
Notable examples for the changes:
  • Search and Replace including connected Modifiers or only in connected Modifiers
  • Quickly select Loaders, Savers or both with a button click
  • Improved efficiency and stability
  • Much improved user experience with QuickSelect, the Stay open Checkbox, and the more intelligent Remember Inputs Checkbox
2020-07-06 15_57_17-Change Strings.jpg
The full Changelog for Change Strings 1.2:
ChangeStrings 1.2 (06.07.2020)
  • Redesign of the UI to make space for all the new features
  • The UI now looks correct on a higher UI scale
  • All text inputs now have a clear button
  • Remember Inputs will keep its check status even if unchecked
  • Options to change Filepaths individually for Loaders, Proxys and Savers
  • Support for Styled Text in tools like the Text+ and Text3D
  • Quickselect:
  • Select Loaders, Savers or both with a single button click
  • Change Strings remembers your previous selection and can revert back to it
  • Support to search and replace in Modifier Names and Expressions
  • A new Tristate Checkbox is added for Modifiers
  • Toggle between no Modifiers, include Modifiers and only Modifiers
  • This will only change connected Modifiers not connected Tools in general
  • A new checkbox was added to keep Change Strings open even after clicking OK
  • A new checkbox was added to the Advanced Settings to reduce the console messages of Change Strings. It is on by default, meaning it will print its actions to the console.
  • The main Search and Replace operation was consolidated which makes it easier to add features and made the operation much more robust:
  • Change Strings can now properly find and replace single dots “.”
  • Previously working shortcodes such as “%l” are found and replaced much quicker without triggering a loop
  • Support for the uppercase letter shortcode “%u”
  • Support for all letters shortcode “%a”
  • Searching and replacing single characters is much more efficient
  • General improvements to the operation make it much more robust
  • Improvements to the loop counter make it pretty much impossible for Change Strings to fall into an endless loop or crash
  • The Max Replace Limit will now limit the replacements for each input as well
  • Due to these improvements, the default Max Replace Limit increased to 30
  • Change Strings handles the switching between Local and Global Saving modes much better (Fusion Standalone) and makes sure variables are correct once it closes (DaVinci Resolve and Fusion Standalone)
  • Fixed minor issues with the Resolve or Global Saving mode
  • Updated the manual for the new UI and features

As always the download link for this and all previous versions is here:
https://noahhaehnel.com/blog/manual-changestrings/2
You do not have the required permissions to view the files attached to this post.