Skip to main content
Solved

Distance calculation per pipe segment


peteralstorp
Contributor
Forum|alt.badge.img

Hi, fellow FME-lovers!

 

I have an interesting problem that you can help me solve in an efficient way.

 

I have many pipe segements as solids in an ifc-file, see example in Test2.ifc. The pipes are in 3D and can be connected in all directions. (I'm not sure about the fittings but for now don't mind them.). Now, I need to calculate length per segment and I started working no a complicated scripts (2D and algebra...) but there must be more of an FME-way. I'm thinking along the lines of creating a center line from pipe start to end...

 

If you have any ideas I will gladly listen. 

 

Bonus: what if segments are bent? Will this be handled in you solution?

 

Peter

Best answer by virtualcitymatt

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.

extrusion 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. 

 

getExtrusionVectorThe 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.

 

 

 

View original
Did this help you find an answer to your question?

9 replies

virtualcitymatt
Celebrity
Forum|alt.badge.img+35

So, if you just need the 2D length this can be achieved fairly easily.

SurfaceFootprintReplacer > Dissolver (to get one single polygon) > CenterLineReplacer. This should give you a pretty decent centerline (including the curves).

Next use a Clipper with the SurfaceFootprintReplacer polygon as the Clippers and the Centerline as the Clippee. It worked well in your test data, however, I'm not quite sure how you'd want to handle the T-junction.

If you needed this in 3D that would be a little more tricky. This would not be a very helpful process for vertical pipe sections


peteralstorp
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • October 1, 2021
virtualcitymatt wrote:

So, if you just need the 2D length this can be achieved fairly easily.

SurfaceFootprintReplacer > Dissolver (to get one single polygon) > CenterLineReplacer. This should give you a pretty decent centerline (including the curves).

Next use a Clipper with the SurfaceFootprintReplacer polygon as the Clippers and the Centerline as the Clippee. It worked well in your test data, however, I'm not quite sure how you'd want to handle the T-junction.

If you needed this in 3D that would be a little more tricky. This would not be a very helpful process for vertical pipe sections

@virtualcitymatt​ Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.


virtualcitymatt
Celebrity
Forum|alt.badge.img+35
peteralstorp wrote:

@virtualcitymatt​ Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.

Fair enough - just looking at the data again, are you aware that the lengths are already included in these data?


peteralstorp
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • October 4, 2021
peteralstorp wrote:

@virtualcitymatt​ Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.

@virtualcitymatt​ I'm not sure what you mean, I can't find length? If it's there and if it's actual length (and not just an attribute) then it's interesting. However I would like to find a solution to this problem either way. Thanks for you input, again.


peteralstorp
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • October 4, 2021
peteralstorp wrote:

@virtualcitymatt​ Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.

@virtualcitymatt​ I found it now. Ouch this trait-concept is difficult for me. Thanks again!

 


peteralstorp
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • October 4, 2021
peteralstorp wrote:

@virtualcitymatt​ Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.

@virtualcitymatt​ Just spoke to my collegue, he knew but the problem seems to be that not all objects (in a full data set) has valid length attributes. So the problem remains!


virtualcitymatt
Celebrity
Forum|alt.badge.img+35
  • Celebrity
  • Best Answer
  • October 4, 2021
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.

extrusion 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. 

 

getExtrusionVectorThe 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.

 

 

 


peteralstorp
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • October 6, 2021
peteralstorp wrote:

@virtualcitymatt​ Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.

@virtualcitymatt​ Thank you so much for your effort, Matt! We'll test this approach on a larger data set to see if the will be the whole or a part of the solution. We are so grateful for your help.


virtualcitymatt
Celebrity
Forum|alt.badge.img+35
peteralstorp wrote:

@virtualcitymatt​ Thanks, Matt! That's interesting but I need the correct lengths so the solution must account for 3D.

All good, I lernt something so very much worth it! Cheers and good luck


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings