# How can I write a Python script to turn all normals on a curve to face outward…!

I’ve completed a few professional projects in C#/Unity, have worked through 90% of Microsoft’s Beginners Guide to Python, just started Python the Hard Way and have done a bunch of beginner Blender Python tutorials. I’m kinda starting to become familiar with Blender’s api.

I’m currently trying to build a network of interchanging, overlapping roads similar to the image below, which is then wrapped into ball of twine (but roads). I’ve got one road working, as seen in this tutorial, then wrapped it into a ball with this answer.

The following is my current effort (file link here ):

You can also see this attempt as the blue ball in centre right of the following image (the other images are examples of my ultimate goal):

Here it is in 3D! =D

Junction Test01014 by reverendspeed on Sketchfab

My problem is I can’t seem to get the roads to all face outwards - the beziers are being bent somewhat randomly. I’ve been pointed in the direction of this control , but unfortunately I’d need to apply all my modifiers and then change the direction of the bezier control points independently - which obviously slows iteration to a crawl.

I’ve been trying to think of what kind of code I need to get all the normals oriented correctly - presumably:

I import Math and Mathutils select all the curve points (bpy.ops.curve. select_all ( action=‘TOGGLE’ )) and get a Vector3 list of the curve points Going through each point, I’d get a Vector3 from the centre of the bounding box to the current point Then set the bounding box quaternion to face the Vector3 direction… …But I’m not sure how I’d do that. Or where I’d get the bounding box centre of a Curve - or if I can get that box after the curve has been twisted up by the modifiers.

If I try to apply the rotation, will this happen to the modified object or the underlying data? Would it be possible to undo this change when I want to unroll the sphere and edit the underlying bezier?

I’m really confused, folks. I think I’ve talked myself into a corner here, and I’m not sure where to start with the code. I’d really appreciate any suggestions you could make.