impworks Logo - a grinning imp in flight

V5I: Using Eco To CSV / CSV to Eco

Tuesday, July 4th, 2006

A minor update to last nights scripts to make them more useful (they now allow instances to be deleted) and some basic instructions on using them.

Download: ecocsv.zip (5Kbyte Zip Archive)

This file includes two python files ecotocsv.py and csvtoeco.py. An ecosystem consists of a number of instances of the objects that make it up.

ecotocsv.py, when run with an object with an EcoSystem texture produces a CSV (Comma Separated Value) file that can be loaded into a text editor and many spreadsheet packages. Each line in the CSV file contains information about one instance in the EcoSystem. The typical first few lines of CSV file produced by ecotocsv.py would look something like:


Instance,Position X,Position Y,Position Z,Rotation X,Rotation Y,Rotation Z,Scale X,Scale Y,Scale Z,Filename,Action
0,122,157,83,0,9,351,0.92,0.5,1.2,\moje inf\square stone 2.vob,T
1,128,153,83,1.2,358,351,0.88,0.81,1.17,\moje inf\square stone4.vob,T
2,126,160,83,9,352,6,0.83,0.95,1.03,\moje inf\square stone 8.vob,T
3,123,154,83,0,351,349,0.97,0.95,1.07,\moje inf\square stone 2.vob,T

csvtoeco.py, when run on the same object with the same EcoSystem applied as before (without repopulation or other runs of csvtoeco.py on it) modifies the EcoSystem’s instances. After running ecotocsv.py and before running csvtoeco.py I would suggest saving your file so if the changes don’t work quite as you expected you can modify the CSV file again, reload the scene and try it again.

The CSV file has Twelve Columns:

  1. Instance
  2. Position X
  3. Position Y
  4. Position Z
  5. Rotation X
  6. Rotation Y
  7. Rotation Z
  8. Scale X
  9. Scale Y
  10. Scale Z
  11. Filename
  12. Action

Instance is the number of the instance in the EcoSystem. Don’t edit this number.

Position X, Y and Z are the X, Y and Z coordinates of the instance.

Rotation X, Y and Z are the X, Y and Z rotations applied to the instance.

Scale X, Y and Z are the scale factors of the instance.

Filename is the filename of the instance’s base object. Editing this has no effect when csvtoeco.py is run.

Action is an action to be carried out on the instance. It can either be T for Transform or D for Delete. If it is T any changes to Position, Rotation or Scale you make will be applied to the instance on running csvtoeco.py. If it is D this instance will be deleted.

Example 1. Deleting the 2nd Instance from the file above


Instance,Position X,Position Y,Position Z,Rotation X,Rotation Y,Rotation Z,Scale X,Scale Y,Scale Z,Filename,Action
0,122,157,83,0,9,351,0.92,0.5,1.2,\moje inf\square stone 2.vob,T
1,128,153,83,1.2,358,351,0.88,0.81,1.17,\moje inf\square stone4.vob,T
2,126,160,83,9,352,6,0.83,0.95,1.03,\moje inf\square stone 8.vob,D
3,123,154,83,0,351,349,0.97,0.95,1.07,\moje inf\square stone 2.vob,T

Example 2. Lining the instances X positions up


Instance,Position X,Position Y,Position Z,Rotation X,Rotation Y,Rotation Z,Scale X,Scale Y,Scale Z,Filename,Action
0,122,157,83,0,9,351,0.92,0.5,1.2,\moje inf\square stone 2.vob,T
1,122,153,83,1.2,358,351,0.88,0.81,1.17,\moje inf\square stone4.vob,T
2,122,160,83,9,352,6,0.83,0.95,1.03,\moje inf\square stone 8.vob,T
3,122,154,83,0,351,349,0.97,0.95,1.07,\moje inf\square stone 2.vob,T

Leave a Comment

impworks © Copyright Mark Caldwell 1996 - 2024