Solved

Moving middle of text to a coordinate


Badge +4

I have a database with fields for x-coordinate, y-coordiane and a textstring.

 

Now ik have to create a Microstation dgn-file with the middle of the text on the xy-coordinate.

I'm using FME Desktop 2015.0

 

In the workbench I start with a VertexCreator. Then I use LabelPointReplacer to place the text at the coordinate, but the coordinate is at the bottomleft corner of the text.

 

When I set igds_oiginal_justification to 7 (centre-centre for Microstation), the coordinate moves to the middle of the text. So the text is not on the correct coordinate.

How can I move the middle of the text to the coordinate?

icon

Best answer by lenaatsafe 26 January 2016, 23:23

View original

12 replies

Userlevel 2
Badge +16

I have not tried this, but I would try using the format attributes instead of creating a label point.

The format attributes can be found in the Feature type settings:

Hope this helps.

Badge +3

HI.

1. extract bounds of text using Boundsexctractor.

2. replace by centerpoint and extract coordinates.

3 use a Affiner to move the centerpoint to intended labelinsertionpoint.

use Target - Center - 1/2 of bounds

in affiner this would be:

A: 1,0,@Value(T_x)-@Value(C_x)-(@Value(_xmax)-@Value(_xmin))/2

B:@Value(T_y)-@Value(C_y) -(@Value(_ymax)-@Value(_ymin))/2

4 use labelpointreplacer on text attribute.

Previous process conumes the text, but it is in "fme_text_string". Use attributeexposer and expose it prior to using the Affiner.

i alkso believe that the format attributes should be usefull in this respect, never used dgn writers before though.

Badge

Hi @raimond,

I think your approach is perfect: first creating a point with VertexCreator and then replacing it with a text using LabelPointReplacer absolutely makes sense. If this text feature was written into DGN right away, it would have the default LB (left bottom) justification. So the next step is setting the proper text justification. You are right, this can be done with a format attribute, however the correct attribute to use is igds_justification rather than igds_original_justifiation (igds_original_justification is attribute read by the Reader that indicates what justification was used when the text was placed in MicroStation, this attribute is not used by the Writer). Although, as an alternative to setting igds_justification value manually, I would like to suggest using DGNStyler:

The output text feature might still appear slightly offset. E.g. with the attached workspace I got text coordinates 0.0414,0.0000 instead of 0.0000,0.0000 for the text that has height and width 10 and uses ENGINEERING font. This happens because all fonts have different proportions which DGN Writer is not aware of, i.e. DGN Writer can not calculate the text bounding box and therefore text center location precisely - it can only estimate. The offset depends on the font used and the size of the text feature - in many cases it will be minimal if present at all.

When inspecting your output with Data Inspector, please check igds_original_justification, igds_insertion_x, and igds_insertion_y attribute values as these attributes describe the text original insertion point and justification while other attributes store values calculated for the left bottom corner of the text bounding box (i.e. as if the text had LB justification, this is how MicroSnone2dgnv8.fmwtation handles the texts).

Userlevel 4

Hi @raimond,

I think your approach is perfect: first creating a point with VertexCreator and then replacing it with a text using LabelPointReplacer absolutely makes sense. If this text feature was written into DGN right away, it would have the default LB (left bottom) justification. So the next step is setting the proper text justification. You are right, this can be done with a format attribute, however the correct attribute to use is igds_justification rather than igds_original_justifiation (igds_original_justification is attribute read by the Reader that indicates what justification was used when the text was placed in MicroStation, this attribute is not used by the Writer). Although, as an alternative to setting igds_justification value manually, I would like to suggest using DGNStyler:

The output text feature might still appear slightly offset. E.g. with the attached workspace I got text coordinates 0.0414,0.0000 instead of 0.0000,0.0000 for the text that has height and width 10 and uses ENGINEERING font. This happens because all fonts have different proportions which DGN Writer is not aware of, i.e. DGN Writer can not calculate the text bounding box and therefore text center location precisely - it can only estimate. The offset depends on the font used and the size of the text feature - in many cases it will be minimal if present at all.

When inspecting your output with Data Inspector, please check igds_original_justification, igds_insertion_x, and igds_insertion_y attribute values as these attributes describe the text original insertion point and justification while other attributes store values calculated for the left bottom corner of the text bounding box (i.e. as if the text had LB justification, this is how MicroSnone2dgnv8.fmwtation handles the texts).

I would just like to add this link for reference, which I've found very helpful when working with igds_insertion_x/y earlier, if you want to set the values manually rather than through the DGNStyler.

Badge +4

Hi @raimond,

I think your approach is perfect: first creating a point with VertexCreator and then replacing it with a text using LabelPointReplacer absolutely makes sense. If this text feature was written into DGN right away, it would have the default LB (left bottom) justification. So the next step is setting the proper text justification. You are right, this can be done with a format attribute, however the correct attribute to use is igds_justification rather than igds_original_justifiation (igds_original_justification is attribute read by the Reader that indicates what justification was used when the text was placed in MicroStation, this attribute is not used by the Writer). Although, as an alternative to setting igds_justification value manually, I would like to suggest using DGNStyler:

The output text feature might still appear slightly offset. E.g. with the attached workspace I got text coordinates 0.0414,0.0000 instead of 0.0000,0.0000 for the text that has height and width 10 and uses ENGINEERING font. This happens because all fonts have different proportions which DGN Writer is not aware of, i.e. DGN Writer can not calculate the text bounding box and therefore text center location precisely - it can only estimate. The offset depends on the font used and the size of the text feature - in many cases it will be minimal if present at all.

When inspecting your output with Data Inspector, please check igds_original_justification, igds_insertion_x, and igds_insertion_y attribute values as these attributes describe the text original insertion point and justification while other attributes store values calculated for the left bottom corner of the text bounding box (i.e. as if the text had LB justification, this is how MicroSnone2dgnv8.fmwtation handles the texts).

Hi Lena,

Thank you for your answer.

 

But how can I style text with DGNStyler? I can only style color, cells and lines.
Badge +4

I have not tried this, but I would try using the format attributes instead of creating a label point.

The format attributes can be found in the Feature type settings:

Hope this helps.

I already tried this, but this doesn't work

Badge +4

HI.

1. extract bounds of text using Boundsexctractor.

2. replace by centerpoint and extract coordinates.

3 use a Affiner to move the centerpoint to intended labelinsertionpoint.

use Target - Center - 1/2 of bounds

in affiner this would be:

A: 1,0,@Value(T_x)-@Value(C_x)-(@Value(_xmax)-@Value(_xmin))/2

B:@Value(T_y)-@Value(C_y) -(@Value(_ymax)-@Value(_ymin))/2

4 use labelpointreplacer on text attribute.

Previous process conumes the text, but it is in "fme_text_string". Use attributeexposer and expose it prior to using the Affiner.

i alkso believe that the format attributes should be usefull in this respect, never used dgn writers before though.

When I do the BoundsExtractor, I get th bounds of the point and not the text

Badge +3

When I do the BoundsExtractor, I get th bounds of the point and not the text

Boundsextractor on the text object.

If u have a point with text attribute u must first "place" the text.

Badge

Hi Lena,

Thank you for your answer.

 

But how can I style text with DGNStyler? I can only style color, cells and lines.

Hi @raimond,

It sounds like an older FME. Do you use FME 2014? FME 2015 DGNStyler has Text GroupBox with many text style related settings:

Would you consider an upgrade? You can download the most recent install from http://www.safe.com/support/support-resources/fme-downloads/ If you have a valid AMC, your old license will work. If your AMC has expired, please contact Safe Support through https://support.safe.com/knowledgeSubmitCase to discuss your options.

Badge +4

Hi @raimond,

It sounds like an older FME. Do you use FME 2014? FME 2015 DGNStyler has Text GroupBox with many text style related settings:

Would you consider an upgrade? You can download the most recent install from http://www.safe.com/support/support-resources/fme-downloads/ If you have a valid AMC, your old license will work. If your AMC has expired, please contact Safe Support through https://support.safe.com/knowledgeSubmitCase to discuss your options.

Hi @Lena,

I use FME 2015.0. DGNStyler has only Color, Cells en Lines settings.

I will download 2016 and try with this one.

Badge +4

Hi @raimond,

It sounds like an older FME. Do you use FME 2014? FME 2015 DGNStyler has Text GroupBox with many text style related settings:

Would you consider an upgrade? You can download the most recent install from http://www.safe.com/support/support-resources/fme-downloads/ If you have a valid AMC, your old license will work. If your AMC has expired, please contact Safe Support through https://support.safe.com/knowledgeSubmitCase to discuss your options.

output.dgnworkbench.fmwinput.xlsxHi @Lena,

I am using FME 2016 now.

I almost have the result I want.

 

As example I have an excelsheet with a text and coordinates.

 

I transform it with the workbench and the text is placed with center-center.

 

When I snap on the text, the snappoint is exactly the coordinate, but it is not the middle of the text.

 

When I choose edit text in Microstation and don't change the text but simply accept it, then the snappoint is the middle of the text, but not the correct coordinate.

 

FME doesn't place the middle of the text on the coordinate.
Badge +4

Hi @raimond,

It sounds like an older FME. Do you use FME 2014? FME 2015 DGNStyler has Text GroupBox with many text style related settings:

Would you consider an upgrade? You can download the most recent install from http://www.safe.com/support/support-resources/fme-downloads/ If you have a valid AMC, your old license will work. If your AMC has expired, please contact Safe Support through https://support.safe.com/knowledgeSubmitCase to discuss your options.

Hi @LenaAtSafe

I changed the font type to number 1 (Working) and the problem was solved.

Thanks for your help

Reply