Evaluate a CURVE point from a percentage?

Hi,

is there a way to evaluate a curve point (world space) from a percentage (offset factor) ?

image

I only found the closest_point_on_mesh function but I cannot make it work:

dg=bpy.context.evaluated_depsgraph_get()1
C.selected_objects[0].pose.bones[0].constraints[0].target.closest_point_on_mesh(origin=mathutils.Vector((10,10,10)),depsgraph=dg)

Object 'NurbsPath' could not create internal data for finding nearest point

the object I am working on (selected/active) is a curve

>>> C.selected_objects[0].pose.bones[0].constraints[0].type
'FOLLOW_PATH'

>>> C.selected_objects[0].pose.bones[0].constraints[0].target.type
'CURVE'

thanks for your help

Off the top of my head, you could put an empty on the path with a Follow Path constraint, put the influence % where you want it, and get the location of the empty pretty easily

indeed, I used bones but that should do the trick (stupid of me)

not much doc around NurbsPath
I could also convert to bezier…meh

I cannot mod the offset_factor, the bones does not move

bpy.ops.object.mode_set(mode='POSE', toggle=False)    
endBoneConstraints[0].offset_factor = 0.6

I tried with empties, they all appear at the same position

for index in range(1,100):
        bpy.ops.object.mode_set(mode='POSE', toggle=False)    
        endBoneConstraints[0].offset_factor = 1/index

        bpy.ops.object.mode_set(mode='EDIT', toggle=False)
        empty = bpy.data.objects.new("Empty"+str(index), None )
        bpy.context.scene.collection.objects.link( empty )
        empty.location = (endBone.head.x,endBone.head.y,endBone.head.z)

I’m not sure why you’re using bones and setting the empty to them. You can just use a Path and an Empty, set the Path Offset with offset_factor, the empty will move to that point, and then you can get the location of the empty and do whatever you’re doing with bones with that location

the whole idea is to anim a bone chain a long a path
so I am open to suggestion, it should be a feature

spline ik cannot be animated

and follow path allows only one bone to follow the path

I need a mix of both features, I thought blender could do that easily in 2022

Couldn’t you use an IK constraint and just have the control bone follow the path?

I need the whole bone chain to follow that path
I mean there are tons of casse where this is necessary

a snake, a roller coaster, a tentacle, anything that follows a path

I’m pretty sure this is possible, I’ve definitely seen it done in Blender, but it’s a bit out of my depth as I’ve never personally done it. Hopefully someone comes along with a solution :slight_smile:

oh yes ! I made it
the issue was that I set the pose mode, while it apparently rather works in edit mode

the thing is that I have quiet a lot of bones, so I want to automatize the process :slight_smile:

1 Like

you can interpolate a biezer curve using mathutils

https://docs.blender.org/api/blender_python_api_current/mathutils.geometry.html#mathutils.geometry.interpolate_bezier

1 Like

thanks everyone for your support

now I just have to make the other armature follow that first armature

I am sooo lazy lol…