PixInsight Forum

Software Development => New Scripts and Modules => Topic started by: mschuster on 2017 January 18 13:53:17

Title: New script for renaming views and previews
Post by: mschuster on 2017 January 18 13:53:17
A new script Utilities > ViewIdReplace should appear as an auto update soon.

Especially during script testing, but also more generally when processing, I often end up renaming the id's of newly created views and previews.

I envision a view id renaming script that accepts a pattern and a replacement string. Multiple instances of this script may be created in the workspace.

Then I drag the appropriate instance onto the view or preview rather than manually renaming.

Here are some examples.

• When I drag a view to create a clone, I want to replace the "_clone" in the name with something else like "_work". This will do it.

(http://mschuster.zenfolio.com/img/s12/v175/p2176894687.png)

So you launch the script, specify a pattern and a replacement, drag an instance onto the workspace, optionally give it a name, and then drag it to the view you want to rename.

• When I create a new preview, I want to replace the "Preview01", or whatever the ending digits are, with something else like "work". This will do it, using a regular expression of the form /pattern/. Here the "." matches any character, and the "*" matches the preceeding pattern 0 or more times. So ".*" matches anything, and the entire id gets replaced with "work":

(http://mschuster.zenfolio.com/img/s5/v123/p2176894692.png)

• When I open two images with the same name, I end up with digits appending one or both, like "integration" and "integration1". Maybe I want to replace the ending digits, if present or not, with something else like "_work". This will do it. "\d*" matches 0 or more digits, and "$" matches the end of the id, so the replacement applies only at the end:

(http://mschuster.zenfolio.com/img/s6/v135/p2176894688.png)

The documentation has a couple more examples, and both the documentation and tooltips show the various pattern options that are available.

Note when the script is open, you cannot drag an instance directly onto a view (error appears), you must drag it onto the workspace, dismiss the script, and then drag the instance. This limitation may be removed in a future release.
Thanks,
Mike
Title: Re: New script for renaming views and previews
Post by: Andrew J on 2017 July 20 15:02:26
mschuster,

Thank you for developing and sharing this script. I always forget to rename my views to the names used in my PixelMath logic. Now all I have to do is add this script to my process container before the PixelMath scripts and it renames the views to match the names I have in PixelMath. Brilliant!! This is a really handy script.

Andrew J
Title: Re: New script for renaming views and previews
Post by: mschuster on 2017 July 20 20:17:08
Thank you Andrew.