Hi, Python noob with a very specific question here.
Is there any “value” in the Python API that allows me to check if the pivot point of a selected object is either inside or outside the frame of the camera? Something which returns a “true”/“false” state maybe?
There is an included function in the bpy_extras module that will give you the viewspace coordinates of a 3d point. Here is an example function that you could plug into your script:
The goal of my script is to move a selected object along its Y-axis until its pivot point matches with the edge of the camera frame.
I went about this by creating a while-loop which moves the object one very small length at a time, and if the state of “inframe” changes, the loop ends. At the moment however, the loop runs forever, crashing Blender.
Do you want object to move while Blender struggles to render a frame? I don’t think this is possible. I could be wrong, ofc.
If not, you should move object on frame change, before or after. Idk if this is still valid but should be something similar.
Your while loop is calling while True. You need to have it call the inframe() function. You also don’t need that first if statement, and that offset is very small. If you absolutely need that precision, it will take a while to process.
while inframe():
bpy.context.active_object.location[1]-=.00001