peteralstorp wrote:
@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):
vec=feature.getGeometry().getExtrusionVectorXYZ()
_line=FMELine()
_line.appendPoints([(0,0,0),vec])
_len=_line.getLength(True)
feature.setAttribute("_len",_len)
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.