@virtualcitymatt Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.
Ahh that's too bad.
The next thing I've seen is that the pipe sections that are not joins or corners seem to be read by FME as FMEExtrusion geometry - this is great because the extrusion is just a vector which is stored in the geometry.
The downside is that there is no transformer to extract this, but fortunately there is some pretty simply python that can be used to get it and calculate the length.
Here is a screen shot from a small workspace which just filters out the unsupported geometries types (we just want the IFME Extrusion.
The Pyhton Caller is used to extract the extrusion vector and create a _len attribute from it.
Here is the python inside the transformer:
import fme
import fmeobjects
from fmeobjects import FMEFeature, FMELine, FMEGeometryTools
class FeatureProcessor(object):
def __init__(self):
"""Base constructor for class members."""
pass
def input(self, feature):
#Here we get the extrusion vector from the pipes, create a line feature out of it and calculate the lines length
#extract the vector
vec=feature.getGeometry().getExtrusionVectorXYZ()
#create an empty line
_line=FMELine()
#add two points to the line, 0,0,0 (the origin) and the end of the vector we extracted above)
_line.appendPoints([(0,0,0),vec])
#extract the length of the lines (the "True" incuicates a 3D Length)
_len=_line.getLength(True)
#dd _len as an attribtue to the feature
feature.setAttribute("_len",_len)
#output the feature with a new attribute
self.pyoutput(feature)
def close(self):
"""This method is called once all the FME Features have been processed
from input().
"""
pass
The important stuff is Indie the 'Input' function.
This of course only works on those pipe sections which are read as extrusions, sadly not the bends or joins.