Skip to main content

Folks, I'm trying to create some polyline labels in a CAD writer but using some alternative label positions.

By default the label seems to be placed dead centre on the line. Depending on the justification of the inserted text (Bottom Left, Middle Centre etc) you can move the label relative to the label point. However I want to offset the the label a certain distance from this placement.

I tried to use the OffsetCurveGenerator and this almost works. However there is some complexity here. There are rules the LablePointPlacer is using to determine "which way is up" so that no matter the orientation of the polyline (drawn direction) the label is always "up" based on standard plan labelling rules.

The OffsetCurveGenerator dutifully offsets lines but the concept of "left and right" based on the orientation of the drawn polyline means the offset line is sometimes "above" or "below" the target polyline.

If I had to come up with some rules I'd create a line perpendicular to the polyline to be labelled through the label point and place my insertion points along this perpendicular line with my labels parallel to the target label at defined offsets from the target line.

Any thoughts on some innovative labelling approaches?

FME always uses some geometry for the location.

And the labelpointreplacer indeed guarantees upright posture.

So to offset or some other transform, you need to transform to the desired location.

You can also just create the location first and then add text.

I tried setting all or some of the autocad_parameters with respect to text; they have no effect on the result. fme does not set them.


Hi @andyew have a look at the autocad_alignment_ attributes in the AutoCAD reader Doc. They might be useful to edit here for you're output. Have you considered looking into the MapTextLabeller? This is an additional plug but it looks like you can request a free trial of it to test it out.


Thanks @gio You are 100% correct. With the help of a couple of other links I was able to adapt their procedures to produce a desired result.

The key was the LabelPointReplacer. Since it does the "heavy lifting" of determining the correct label rotation it then becomes the challenge to create a new label location based on the existing label. With the label rotation and the label X and Y it's possible to create a new line based on these parameters. See here for the procedure https://knowledge.safe.com/questions/43396/create-line-from-point-and-point-heading.html .The newly created line can the be offset with confidence. LEFT will always be "above" the label line and "RIGHT" will always be below. See here for OffsetCurveGenerator https://knowledge.safe.com/questions/40073/how-to-create-offset-parallel-lines.html

 

 

So in that attached image the workflow is this.

 

Use the LablePointReplacer to obtain the LabelRotation and the X and Y origin. Us the coordinate extractor to get the X and Y and use the AttributeExposer to get the "LabelRotation" Use the VertexCreator to add a coordinate to your starting point. In this case to get the correct line segment created I had to add to the X coordinate(I used a nominal 5 metres) rather than the Y as given in the linked example. Next apply the LabelRotation to the Rotator. You now have a 5m long line segment that starts at the label origin and is parallel to the original line. The next step is to use the OffsetCurveGenerator to offset the line segment. As mentioned, the line segment is correctly orientated for labeling so the "LEFT" and "RIGHT" offsets offered in the OffsetCurveGenerator has a uniformly predictable outcome for the purpose of Label offsetting. I applied an offset that was just a bit further than the height of the existing label. Lastly, yet another LabelPointReplacer to place the new offset label. Worked perfectly.


Hi @andyew have a look at the autocad_alignment_ attributes in the AutoCAD reader Doc. They might be useful to edit here for you're output. Have you considered looking into the MapTextLabeller? This is an additional plug but it looks like you can request a free trial of it to test it out.

Thanks @MattAtSafe. I did look at the MapTextLabeller but it was way overkill for the simple offsetting I wanted to do. I have managed to develop a robust process leveraging existing Trasnformers. Quite relibale really.

 


Reply