Skip to main content

I have autocad files i am pulling some polyline entities from. i am currently using the PointVertexReplacer to extract the coordinates of the polylines.

The problem i am having is that i began expecting 3 vertices; (a begin, a vertex, and an end). I encountered a line with 4 vertices. Previously i just iterated with AttributeFilter through 0,1,2 as these 3 vertices.

But because 1 line has 4 vertices the 3rd vertex is not the end. (it would be nice if there were a begin/end attribute that could be grabbed.)

I am trying to figure out how to filter these prior to this and can only come up with using the feature information but cannot expose this information. I can see the number of vertices value but it is not exposable. I assume i could do a count but it seems that would require quite a few more transformers.

Can anyone suggest how to accomplish this?

 

Use a list element counter after the coordinate extractor. From there you can count the elements, use a ListIndexer of 0 to get the 1st coordinate and a ListIndexer of @value(_element_count)-1 to get the end coordinates.

 

This will work on any line regardless of the number of vertices.

 

Workbench example

 

3 vertices

4 vertices

 

 


Even simpler than using the element count is:

Use the CoordinateExtractor transformer and use index 0 for the start and index -1 for the en of the line.

FME has the capability to count backwards from the end using -1, -2 etc.

Hope this helps.


Even simpler than using the element count is:

Use the CoordinateExtractor transformer and use index 0 for the start and index -1 for the en of the line.

FME has the capability to count backwards from the end using -1, -2 etc.

Hope this helps.

i edited my question. if they were lines i could do that. they are polylines so possibility of more that 2 vertices. I have done what you suggest but have index 0,1,2,3. in one case 3 is the end. in all other cases 2 is the end.


i edited my question. if they were lines i could do that. they are polylines so possibility of more that 2 vertices. I have done what you suggest but have index 0,1,2,3. in one case 3 is the end. in all other cases 2 is the end.

Try index -1.

It will always be the end.

And 0 will always be the start.


Even simpler than using the element count is:

Use the CoordinateExtractor transformer and use index 0 for the start and index -1 for the en of the line.

FME has the capability to count backwards from the end using -1, -2 etc.

Hope this helps.

Like this:

Start:

End:

Make sure you set the Mode to Specify Coordinate.


Reply