Difference between revisions of "Generating texture lists"

436 bytes removed ,  17:57, 15 February 2008
improved formatting and removed explicit references to my name as that is not relevant for the tutorial
imported>Razorwing
imported>Amorilia
(improved formatting and removed explicit references to my name as that is not relevant for the tutorial)
Line 2: Line 2:
[[Category:Tutorials]]
[[Category:Tutorials]]


==Introduction==


Niftexdump is a Python script written by [http://niftools.sourceforge.net/forum/profile.php?mode=viewprofile&u=4 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 [http://www.silgrad.com/ 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.
Niftexdump is a Python script that batch-processes nif files to generate a report of the files' material settings. Its 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 [http://www.silgrad.com/ 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.
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 the 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 [http://niftools.sourceforge.net/forum/profile.php?mode=viewprofile&u=4 amorilia]. For more information about installing those, see the [http://cs.elderscrolls.com/constwiki/index.php/Nif_Optimization#Installation Nif Optimization] wiki article. Once you have it installed, proceed with the steps below.
==Requirements==


First you need to install Python. After that you need to install PyFFI. For more information about installing those, see the [http://cs.elderscrolls.com/constwiki/index.php/Nif_Optimization#Installation Nif Optimization] wiki article.


'''1.'''
==Running the Script==


Choose "Run" on Windows' Start Menu, type cmd in the textbox and press the OK button to launch DOS.
Choose "Run" on Windows' Start Menu, type cmd in the textbox and press the OK button to launch DOS. 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


'''2.'''
Lastly hit the return key to execute the command. Next, enter the following command:


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 <tt>cd C:\Python25</tt>. Lastly hit the return key to execute the 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&mdash;you most likely will&mdash;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.


'''3.'''
For example, 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


Now enter the following command: <tt>python scripts\niftexdump.py "<local path to mesh folder>" > "<local path+filename of log file>"</tt> 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.
C:\Program Files\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).


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).
Note that you '''can''' enter the command as


python scripts\niftexdump.py "C:\Program Files\Oblivion\Data\meshes\ST\book"


You '''can''' enter the command as it is now - <tt>python scripts\niftexdump.py "C:\Program Files\Bethesda Softworks\Oblivion\Data\meshes\ST\book"</tt> - 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".
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. For example, suppose you have a directory


c:\logs


Put together, the command in my case is: <tt>python scripts\niftexdump.py "C:\Program Files\Bethesda Softworks\Oblivion\Data\meshes\ST\book" > "C:\python\book.txt</tt>
where you save your logs. It doesn't matter where you save the logs, the only things to keep in mind is to add quotation marks if there are blankspaces in the path and/or filename and also to add the file extension. In the above case the log would be "C:\logs\book.txt".


Put together, the command in my case is:
python scripts\niftexdump.py "C:\Program Files\Oblivion\Data\meshes\ST\book" > "C:\logs\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.
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.
Line 45: Line 55:




'''4.'''
==Inspecting the Log File==
 
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.''


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 may stop when it comes across a nif it doesn't understand (you should report such cases on the [http://sourceforge.net/tracker/?group_id=149157&atid=776343 bug tracker]).


Sometimes one wants to run searches through all the logs, and if you have a great deal of them then you can save some time by using programs that can run batch searches like that. 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 [http://notepad-plus.sourceforge.net/ "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.
Sometimes one wants to run searches through all the logs, and if you have a great deal of them then you can save some time by using programs that can run batch searches like that. 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 [http://notepad-plus.sourceforge.net/ "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.


<center>[[image:Tut Niftexdump 4 Notepad++.jpg|159px|Searching logs in Notepad++]]</center>
<center>[[image:Tut Niftexdump 4 Notepad++.jpg|159px|Searching logs in Notepad++]]</center>
Anonymous user