The basic way:
data_file = open("/path/to/file.txt", "r")
for line in data_file:
# strip white space from line
line = line.strip()
# ignore empty lines
if not line: continue
# split using your seperating character
x, y, z = line.split(',')
# convert string to float values
x, y, z = float(x), float(y), float(z)
# now do something with your values, e.g.
newPoint = OpenMaya.MPoint(x, y, z)
You could also use the csv module.
See http://docs.python.org/library/csv.html#examples for examples
Cheers,
On 22 Sep., 00:46, Dimitry <[email protected]> wrote:
> Hey Everyone,
>
> I have a simple question -
> how add data from text file.
>
> for example I have text file(what laying in the same order as maya
> file) with 3dpoint List
> 0,1,1
> 2,4,5
> 5,56,6.5
> 3,3.5,0
>
> How it is possible to translate it to 3dPoint array in maya.
>
> Many thanks for every advise!
>
> Cheers!
> Dimitry
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---