Setting the points of a nurbs curve to (XYZ) in worldspace [duplicate]

Im trying to snap the ends of a curve, to two points in space. However, I can't get past the fact that It requires worldspace input of a matrix instead of a vector. I've tried to convert worldspace to local, and backwards but its not my strongpoint.

Any ideas are more then welcome. Thank you!

import bpy
from bpy import context, data, ops
from mathutils import Euler, Matrix, Quaternion, Vector

# Create bezier path.
#ops.curve.subdivide(number_cuts=0)
ops.transform.resize(value=(2.0, 2.0, 3.5))
ops.object.mode_set(mode='OBJECT')
curve = context.active_object
curve.name = 'line'

# snap one end of curve to A other to B
location_a = (1,1,0) # (XYZ)
location_b = (2,2,0) # (XYZ)

curve.data.splines[0].points[0].co = Vector(location_a)
# error ->
# Line 20 -> ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 4 items, not 3
$$$$

• Have marked this as a dupe.. . IMO The issue here is the 4th dimension of the nurbs curve is twist or radius can't remember, anyway as with all data coordinates these are in local coordinates. For most cases simply tack a 1 on as 4th coordinate. If you feel they don't answer your question, please inform and will re-open and answer or someone else using methods shown in dupe links above. – batFINGER Jul 12 '20 at 14:35
• Or as @RayMairlot oft links to, whats known as the XY Problem – batFINGER Jul 12 '20 at 15:05
• Perfect answer, very helpful, thank you! I hadn't realised the 4th dimension was something else. I had misdiagnosed it as some sort of matrix, but it wasnt. Thank you! – Henk Kok Jul 12 '20 at 15:58