Thursday, September 9, 2010

Restoring Missing Painter Variant xml dab-flags (Mac OSX Leopard)

July 15, 2009 by brush  
Filed under Painter Brushes, Variant xml

Please also see my previous article: Lifting the Dampers off SaveRestoreDamping.

This is a demonstration of using custom AppleScripts in TextWrangler to add missing dab flags (such as SaveRestoreDamping and SaveRestoreMouseParams to Corel Painter brush variant xml files.

Disclaimer
Although these scripts have been tested, it is important that before editing your brush variant xml files, you first ensure that you have a backup copy of the originals.

Neither David Gell nor jitterbrush.com accept responsibility for any loss of data or performance issues relating to your computer as a result of downloading or using these scripts.

Terms of Use
You are permitted to modify the scripts for your own use, but not to sell or redistribute the originals without my prior consent. Please feel free to e-mail me if you have any suggestions, script modifications you wish to share, or issues relating to using the resources. I would also be happy to modify the scripts to accommodate any dab-flags search strings which the scripts currently fail to recognize.

1. Download and Install the TextWrangler Application

TextWrangler is a freeware text editor for Mac OSX. If you don’t already have it installed, it can be downloaded from the Bare Bones Software product page.

After first installing to your applications folder, it may be necessary to first launch and then close the application in order that a TextWrangler > Scripts folder is installed at the following location;

Users[user name]/Library/Application Support/TextWrangler/Scripts/

2. Download and Install the SaveRestoreDamping AppleScripts

media_1247665544679.png

Download the SaveRestoreDamping zip folder (467 KB)
After unzipping, place the SaveRestoreDamping folder and contents at the top level of the;

Users[user name]/Library/Application Support/TextWrangler/Scripts/ folder as shown in the above Finder screenshot.

3. Open a Brush Library Folder (or Enclosing Brushes Folder) in the Finder

media_1247670413134.png

In the above example, I have first downloaded the Painter 11 Extra content Brushes folder (Mac version) from the Corel download page and unzipped it onto my desktop, before double clicking on the Brushes folder to reveal its contents in the Finder. I am using the column view in the Finder (View menu > as Columns). Note that I have the Brushes folder highlighted in the first column, as we will be next searching all the sub-folders (brush library and category folders).

4. Locate Brush Variant xml Files which have missing dab-flags

media_1247671664921.png

We are now going to perform a boolean search in the Finder, to display any variant xml files in the Brushes folder or sub-folders which do not have a SaveRestoreDamping flag. I am using Mac OSX Leopard, (In Tiger 10.4,  this may require a different search term such as “dab-flags – SaveRestoreDamping” or “dab-flags ! SaveRestoreDamping” ). In OSX 10.5, type the following into the Finder search window;

dab-flags NOT SaveRestoreDamping

After the search has completed, you may have to select “Brushes” again from the Finder window menu bar in order to restrict the search to only that folder/sub-folders. Note that in this example, 382 xml files did not have the SaveRestoreDamping flag.

5. Open the Search Results in TextWrangler

media_1247673721366.png

Click on any file name in the Finder window to highlight it, the choose Edit > Select All from the menu bar (Command + A).
Next, right click (Option + Click) in the Finder results window and choose Open With > TextWrangler from the contextual menu.

Note: for my convenience, I had already changed the file association for the xml files to open with TextWrangler as the default. If you have not done this, you should find TextWrangler listed near the bottom of the contextual menu. In this case, your document icons would also be different to those shown.

After opening the files in TextWrangler, leave the above Finder window open and visible on the desktop. As the search is dynamic, the number of items listed in the results window should decrease when we later run the SaveRestoreDamping_recursive script.

6. How Many?

media_1247674810851.png

Because of the large number of items to be opened, TextWrangler has presented a dialog asking if I really want to open so many. Just click open in this dialog. I could have selected (highlighted) a smaller number to open from the Finder window, but I wanted to test what TextWrangler and the scripts could handle in a single operation.

7. Documents Open in TextWrangler

media_1247675802584.png

In the above screenshot, you can see that the xml documents have now opened in TextWrangler. I have selected the very top document in the Documents drawer to the right. This could be important when we later run the script, as it may determine which file the recursive script starts with (I have not tested this).

You may just be able to make out the outlined text on the left, which confirms that the SaveRestoreDamping flag (and the SaveRestoreMouseParams flag) is missing. The line actually reads dab-flags=”NewFormat|PenStructuredClone”

8. Accessing the Scripts and what they do

media_1247678121353.png

With TextWrangler the front application, clicking on the scripts icon in the menu bar will reveal the scripts menu. The item SaveRestoreDamping actually references the script folder of the same name which we previously installed. To the right of this, you will see that the folder contains three scripts which have been designed to operate as follows;

The About SaveRestore_flags script does nothing more than open an information dialog up, with some basic info. relating to the SaveRestoreDamping and SaveRestoreMouseParams flags. Click on the About SaveRestore_flags in the scripts menu, read the dialog information, then click the O.K button to close it.

*** Please do not click on either of the scripts named below just yet ***

Add SaveRestoreDamping_recursive is the main workhorse script, and is used to do find and replace operations recursively on all documents listed in the TextWrangler Documents drawer (an ambitious 382 in this case).

It is important to note that although the latter two script names suggest that only the SaveRestoreDamping flag is added, the scripts will also add NewFormat and SaveRestoreMouseParams dab-flags if they are also missing. Any existing dab-flags will remain in place, with the exception of SinglePixel, which I believe to have been mistakenly incorporated.

The Add SaveRestoreDamping script performs identical find and replace operations as the recursive script, except only on the current document highlighted in the TextWrangler Documents draw i.e the document open in the main window.

9. Choose the Add SaveRestoreDamping Script

media_1247685008624.png

With the 2 Rank P-D.xml file selected in the TextWrangler Documents drawer, choose the Add SaveRestoreDamping script from the TextWrangler scripts menu. Remember that this script only acts upon the currently selected document as opposed to the ‘Add SaveRestoreDamping_recursive’ script which will crunch through every document listed in the Documents drawer.

10. Testing the Add SaveRestoreDamping Script

media_1247680833265.png

After the script has run, you should now see that the previously missing SaveRestoreDamping and SaveRestoreMouseParams flags have now been added to the xml document. A dialog will also appear, with a reminder to save the file.

Click the Thank You button and then choose File menu > Save. Now look at the original Finder window where you performed the initial search. At the bottom of the window it shows that there are now 381 files listed (at the time of the original search, there were 382). Don’t worry, the missing file has not disappeared into hyperspace or been deleted. Remember that the Finder is currently showing the results of a dynamic search for documents which did not have the search string ‘SaveRestoreDamping’. As you have just saved a document from the original list which now has the SaveRestoreDamping flag, it will no longer appear in the Finder results window.

Note, if ever you run the above script, and a dialog message appears to the effect that “Sorry, operation unsuccessful. Please add the missing dab-flags manually“, it means that the script could not find a match for the current dab-flags string, and therefore could not replace this with a modified string which would include the missing flags. If this happens, please e-mail me with the exact text which is present on the dab-flags line in the document (or send me a copy of the file), I can update the scripts accordingly.

11. Bring on the Cavalry

media_1247688335161.png

O.K, so 1 down, 381 to go. What we could do next is select each item in turn in the Documents drawer and run the ‘Add SaveRestoreDamping’ script on each individual document, but imagine having to do that 381 times. This is where the Add SaveRestoreDamping_recursive script comes to the rescue.

Unfortunately running this script should perhaps come with a health warning, as there will be a lot of screen activity i.e.. dialogs rapidly appearing momentarily and new ones popping up. This is normal behavior for the application, but can be unpleasant to view.

There are essentially two types of dialog; one set which increases in quantity as each reports the number of matches found for the unique string searched. The second type (which I find the most annoying) is a dialog which prompts a request to save the document for each find and replace match before the script moves on to the next document. I have found a workable solution however. After selecting the first document in the TextWrangler Documents drawer and choosing choosing the SaveRestoreDamping_recursive script from the scripts menu, I then hold down the Enter key on the keyboard for between 10 or 20 seconds. This effectively allows multiple acceptances of the default Save button in the respective dialog. I can then look away from the monitor, go for coffee etc. whilst the script is performing its duty. If the script does not complete all the commands before the stored enter commands run out, I simply press the Enter key again for another 15 seconds or so.

If one can ignore the flickering for a moment, it can be interesting (reassuring) to periodically view the original Finder window, especially near the end of the script when the items are finally disappearing from the list (indicating that the operation on those files has been a success – the missing dab-flags restored). TextWrangler does have to be the front application however, whilst the script is running.

Another dialog will be presented when the script has completed all operations on every document in the drawer. This recommends that you check the Finder results window again to view any remaining documents which the script has not been able to correct. It may also be necessary to manually save the first item in the TextWrangler Documents drawer. Final tidying up involves closing all the TextWrangler dialogs before quitting the editor.

Video of the Workflow - flashing images warning;

12. Will the last person out, please turn out the light

media_1247694379411.png
Download this article as a pdf document: Restoring_Painter_dab-flags.pdf (684 KB)
  • Share/Bookmark

Related Posts

  1. Backward Compatibility Variant Conversion (Mac OSX)
  2. xml File Association in 2 Clicks
  3. Lifting the Dampers off SaveRestoreDamping
  4. Pattern Rendering Variants Using the Plug-in Method

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Spam Protection by WP-SpamFree

Optimized by SEO Ultimate