Not enough code shown to be sure but a couple guesses of possible problems.
the variable central_curve_obj is not being set properly
the variable central_curve_obj is set in a different function but not referenced as a global variable both when set and referenced
Either of the above could cause central_curve_obj to be a nonetype object
The thing is, when I do print of context.view_layer.objects.active, it prints the curve. Everything works fine when doing this with Blender running, but when I try to work with its python module only, this happens.
I’m quite new to this. I have used it to set the object to active and change some of its properties, is there something else I should do with the viewlayer?
Your code above is still has many issues to consider:
When constructing a curve like this curve = bpy.data.curves.new(“curve1”, “CURVE”) only a single point is added to the mesh data block. How to specify Nurbs path vertices in python? - Blender Stack Exchange is an old post I answered on BSE that creates a curve from given points. It would need to be updated for linking to collections instead of scene but should help with creating a curve.
context.view_layer.objects.active.rotation_euler = rot
** if you are not setting the active object and only want to get the active object use context.object.rotation_euler = rot
** variables rot, loc, sca are not defined in your code while readers can just plug in numbers every additional error that someone has to fix detracts time from attempting to help with your original issue
Ideally when you post code you want it to be easy for others to copy and paste as such code blocks should be pasted as code use the </> button this also corrects issues with single quote and double quote ascii codes which otherwise have to be replaced manually by the user copying your code.