Hi!
I haw much objects, but me need get depsgraph from only one object. How I can do this?
I’m not sure what you’re asking, but the dependency graph updates when any data is changed. So if you update the dependency graph by updating a mesh, the data and attributes of the mesh will update and you can access that data exactly the same way
I cane use this
depsgraph = bpy.context.evaluated_depsgraph_get()
But I have mach objects and me need depsgraph only one object, not all objects.
Or maybe I can delete objects in depsgraph.object_instances ?
The depsgraph (dependency graph) is a construct that holds the information on pretty much everything that’s going on in the file. its very purpose is to tie together different systems so I’m not sure what you are asking ?
You can get the evaluated object with obj.evaluated_get(depsgraph)
See https://docs.blender.org/api/current/bpy.types.Depsgraph.html
This is what you’re looking for :
depsgraph = bpy.context.evaluated_depsgraph_get()
ob_eval = ob.evaluated_get(depsgraph)
Type depsgraph != type ob_eval
Arf ok !
I didn’t even see that Gorgious pointed out in the same direction.
As with others , I’m not sure what you’re looking for then.
Good luck !
The depsgraph is not an object, it’s a construct that describes objects and their relationships (among other things). What’s your end goal here ?
me net get point intersection ray and only one object
Alright I think I understand.
You’re using bpy.types.ray_cast from an origin point towards a given direction, but it doesn’t work because your target object is blocked by another geometry. You want to cast a ray between a point in space towards a direction and let it only interact with a single object’s geometry.
This should do it
https://blender.stackexchange.com/a/115287/86891
import bpy
from mathutils.bvhtree import BVHTree
dg = bpy.context.evaluated_depsgraph_get()
obj = bpy.context.active_object
obj_eval = obj.evaluated_get(dg)
bvhtree = BVHTree.FromObject(obj_eval, dg)
location, normal, index, dist = bvhtree.ray_cast((0, 0, 0), (0, 1, 0))
print(location)
print(normal)
print(index)
print(dist)
Note the ray cast origin and direction are in object space, so you’ll need to use the inverse matrix to express them in world coordinates. Or apply the transforms on your object.
See https://docs.blender.org/api/current/mathutils.bvhtree.html