Silgrad Tower from the Ashes

Full Version: Generate texture lists with niftexdump
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Niftexdump is a Python script written by amorilia that batch-processes nif files to generate a report of the files' material settings. It's primary application is to give modellers an overview of a large number of models, perhaps because they want an index over Oblivion's files or perhaps because their mod uses a lot of new models. The reports generated by the script makes it very easy to for instance find out which models use a particular texture. This is an important concern for the Silgrad Tower mod, mentioned in the examples below, since the mod uses around 4000 models and changing a texture's filename without researching which models uses it can cause a lot of problems.

Have you forgotten if you actually used a texture on your models you added to your texture folder? Do you want to change the filename and/or folder path of a texture but are worried that will cause 'pinkness' in unexpected places? Do you want to make sure that for instance all your ambient light settings are pure white? All of those problems and more can be solved by using amorilia's niftexdump script.

First you need to install Python, which is a freeware programming language that powers amorilia's script. After that you need to install PyFFI, which is a Python add-on also created by amorilia. For more information about installing those, see the Nif Optimization wiki article. Once you have it installed, proceed with the steps below.

1. Choose "Run" on Windows' Start Menu, type cmd in the textbox and press the OK button to launch DOS.

2. Browse to Python's installation folder by typing cd followed by the local path. The default local path is C:\Python25, so if you installed to that then the command would be cd C:\Python25. Lastly hit the return key to execute the command.

3. Now enter the following command: python scripts\niftexdump.py "<local path to mesh folder>" > "<local path+filename of log file>" and hit return. If you use local paths or filenames with blankspaces in them - you most likely will - then you need to encase them in citation marks, otherwise DOS will interpret them as separate arguments and will not understand the command. You can always use citation marks for paths if you want, it's just that not using them only works as long as there are no blankspaces.

Let's say you want to get information about the models located in a folder called "book" which is a subfolder of "ST" in the root meshes folder. In that case the local path to mesh folder is "C:\Program Files\Bethesda Softworks\Oblivion\Data\meshes\ST\book". It might differ depending on your harddrive setup and where you chose to install Oblivion, but you get the jist of it. A good way of getting the local path if you're unsure is through the folder's adress bar (which you might have to enable through Windows' folder options dialogue).

You can enter the command as it is now - python scripts\niftexdump.py "C:\Program Files\Bethesda Softworks\Oblivion\Data\meshes\ST\book" - but that will mean the information gets printed to the DOS window, which isn't very useful. Instead you'll probably want to print the information to a text document. To do that, write the command you have so far and add a blankspace then a > sign and then another blankspace and then write the local path and filename of the text document you want to create. Personally I save the logs to the folder c:\python because that's what I named my temp folder for running batch operations of amorilia's nif optimizer script. It doesn't matter where you save the logs, the only things to keep in mind is to add citation marks if there are blankspaces in the path and/or filename and also to add the file extension. In my case the log would be "C:\python\book.txt".

Put together, the command in my case is: python scripts\niftexdump.py "C:\Program Files\Bethesda Softworks\Oblivion\Data\meshes\ST\book" > "C:\python\book.txt

The script will execute, which you can tell by the cursor blinking on the row underneath. You'll know when the operation is finished by DOS giving you a new command prompt.

TIP. If you press the up arrow on your keyboard's arrow pad, the last executed DOS command will get reprinted. You can save a lot of time by tweaking a copied command than by writing it over and over again.

[Image: th_Tut_Niftexdump_1_DOS_Commands.jpg] [Image: th_Tut_Niftexdump_2_Result.jpg] [Image: th_Tut_Niftexdump_3_Logs.jpg]

4. There are thousands of models to keep track of in the Silgrad Tower mod and exporting all of them to a single text file isn't a practical solution. It's more convenient to do it folder by folder, for three reasons: It's easier to find information that way, it's faster to update the info for a folder you've worked in, and also because in rare cases the script stops when it comes across a nif it doesn't understand. Note that the latter problem has likely been remedied in the newest version of the script.

Sometimes one wants to run searches through all the logs. There are a number of commercial programs that can find text strings in multiple documents, but if you don't have any then an excellent freeware alternative is "Notepad ++". It's very easy to get started too, just open it up and choose "Search > Find in files...". Browse to the folder you saved the logs to by clicking the "..." button to the right of the Directory textbox. Enter a texture name or other textstring in the "Find what:" textbox, and away you go. You'll get a list of which logs the search occurs in. Open the logs manually and do a search for the textstring, then scroll up to find out what nif it belongs to.

[Image: th_Tut_Niftexdump_4_Notepad.jpg]