I have been trying to colour a mesh along its length with a gradient and have had some success. I found this helpful forum entry which gave me the following result:
However, problems arise when the pipe intersects with itself. Here, the mesh vertices, which are being tested to find at which point on the path they are closest to, are being placed on the path at the wrong point. This means when it comes to assigning a colour, the colour is wrong:
After some persevering I have come up with a solution/work around. I thought it would be useful to post it here in case someone encounters the same problem later on.
I noticed that once the variable pipe brep becomes a mesh the order of things is somewhat lost. As such I decided to split the brep into pieces along the length of the path curve. This way I could then turn those pieces into meshes and colour these meshes with a gradient. As long as there are enough pieces the colours blend nicely and you don’t read the separate pieces.