0

For my current project, I need to grab the mesh data from a randomly generated cylinder. I would like to get the xyz location of all the vertices, see pics below to get a general idea of what I want to do.

enter image description here

enter image description here

Another very important thing is I would also like to grab the camera metadata as well. Eg FOV, location etc. I can then save the data to a text file for later use. Basically, the goal is if I reverse the process and read the metadata stored in that text file I should be able to recreate the same cylinder in the same perspective with the same camera angle! I am not new to python but I am a newbie to Blender's api.

TLDR: Grab all vertice coordinates from the cylinder and corresponding basic camera info as well.

Edited: The dots are just random doodles to get my point across.

Inkplay_
  • 737
  • 1
  • 9
  • 23
  • Found this thread for mesh , I still need to get info from the camera. https://blender.stackexchange.com/questions/1311/how-can-i-get-vertex-positions-from-a-mesh – Inkplay_ Apr 15 '18 at 14:38

1 Answers1

0

Here is the code that made everything work

Getting the mesh data from the model:

ob = bpy.data.objects['Cylinder']
verts = [verts.co for vert in ob.data.vertices]

Getting the location and rotation data from camera:

camera_location = np.round( list( bpy.data.objects['Camera'].location ), 3)
camera_rotation = np.round( list( bpy.data.objects['Camera'].rotation_euler ), 3)

I had to use numpy "np" to round down the outputs, I did the same thing for verts.

Inkplay_
  • 737
  • 1
  • 9
  • 23