- Place the data in a CSV file containing the coordinates and image names.
- Loop over each line of the CSV file:
- use Images as Planes to import each image
- move the image to the location.
Although given that your Z values are identical, you may want to read only the X and Y coordinates.
Here's an example CSV reader that you would have to modify to handle the format of your file
import csv
with open(csvFilename, 'r') as csvFile:
csvreader = csv.reader(csvFile, delimiter=',',
quotechar='|',
quoting=csv.QUOTE_NONNUMERIC)
for row in csvreader:
print(f"{int(row[0])} is ({row[1]}, {row[2]}, {row[3]})")
Once you've decided on your CSV format, replace the print
statement with code to decode a row, use the importer, and move the resulting object.
Here's an example of how to import an image as a plane and move it.
from pathlib import Path
image_file = Path("c:\\tmp\\0001.png")
bpy.ops.import_image.to_plane(files=[{'name':str(image_file)}])
image = bpy.data.images[image_file.name]
image.location = (x, y, z)
So the entire loop looks like this:
import csv
from pathlib import Path
with open(csvFilename, 'r') as csvFile:
csvreader = csv.reader(csvFile, delimiter=',',
quotechar='|',
quoting=csv.QUOTE_NONNUMERIC)
for row in csvreader:
# YOU need to place code here to convert the row entries
# into a file name and set of coordinates
bpy.ops.import_image.to_plane(files=[{'name':str(image_file)}])
image = bpy.data.images[image_file.name]
image.location = (x, y, z)