0
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.