thegarland
10-17-2010, 03:26 AM
Hey everybody,
I'm trying to make a 3D starmap, and I want to write a MEL script that will take a star object that I've modelled, read coordinates from an external text file, and place the object at those coordinates.
The data text file will contain a series of numbers like this:
1 2 3
4 5 6
7 8 9
and so on...
Here is a basic description of what I want to happen in the MEL script:
(1) select the object to be duplicated
(2) open a data file for reading
(3) until the end of the data is read, repeat the following loop
read back one line of data (three numbers)
assign those three numbers to variables X, Y, and Z
duplicate object and move it to the xyz coordinates
end of loop
I know how to take an object and place it at a specific set of coordinates, but what I'm having difficulty with is reading data from an external text file. What I'm specifally having trouble with is knowing how to properly use the fopen command.
It's critical that I am able to draw the coordinate data from an external file because there are over a thousand stars that I need to map, so I need to automate the process.
The Maya command reference has not been helpful, as they don't explain in the examples specifically what each thing does.
If anyone can help me figure this out, I'd really appreciate it.
I'm trying to make a 3D starmap, and I want to write a MEL script that will take a star object that I've modelled, read coordinates from an external text file, and place the object at those coordinates.
The data text file will contain a series of numbers like this:
1 2 3
4 5 6
7 8 9
and so on...
Here is a basic description of what I want to happen in the MEL script:
(1) select the object to be duplicated
(2) open a data file for reading
(3) until the end of the data is read, repeat the following loop
read back one line of data (three numbers)
assign those three numbers to variables X, Y, and Z
duplicate object and move it to the xyz coordinates
end of loop
I know how to take an object and place it at a specific set of coordinates, but what I'm having difficulty with is reading data from an external text file. What I'm specifally having trouble with is knowing how to properly use the fopen command.
It's critical that I am able to draw the coordinate data from an external file because there are over a thousand stars that I need to map, so I need to automate the process.
The Maya command reference has not been helpful, as they don't explain in the examples specifically what each thing does.
If anyone can help me figure this out, I'd really appreciate it.
