Hi everyone. I am a novice in blender python scripting. my project is that i have a 3d model and i want to render its images keeping the camera at different angles. For example i take a picture by keeping the camera at (x,y,z) coordinates. Then i take a second picture at coordinates (x1,y1,z1). The problem that i am facing is that as i move the camera to another location i have to adjust its rotation and translation everytime manually to get the object in the centre and perform rendering. Is there any way to adjust it automatically???. I just move the camera to the coordinates specified in my script and blender automatically takes care of the rotation and translation that i do manually. I have written a few python scripts but nothing could solve this issue. Plz help out if anybody knows.I have done it with the help of ctrl+T but i want to do it with the help of a script
You have to truck the camera to the object select camera and object press ctrl+c
i want to do it with the help of python script do u know any commands
This will track the scene’s active camera to the scene’s active object
import bpy context = bpy.context scene = context.scene object = scene.objects.active camera = scene.camera track_constraint = camera.constraints.get("LOCKTOOBJ") if track_constraint is None: track_constraint = camera.constraints.new('TRACK_TO') track_constraint.name = "LOCKTOOBJ" track_constraint.track_axis = 'TRACK_NEGATIVE_Z' track_constraint.up_axis = 'UP_Y' track_constraint.use_target_z = True track_constraint.target = object
Thanxs this code is working fine. But i think it works for certain camera distances because the camera is facing the origin. If the camera is closer to the object the rendered image top portion gets cut off. Can we adjust this with the distance of the camera from the object in a script??? kindly help
Secondly is there any command for switching on the texture of a model and then switching it off
found an easy solution just move the object down in zaxis half its length.