Rearrange text according to new annotationstyle/dimstyle

Hi there,
I have a question concerning annotationstyles and their alignment.
I want to create polysurfaces out of a text and it’s working fine with TextEntity.CreatePolySurfaces Method.

The problem I am having is, that sometimes I need to change the dimstyle, as the Method needs a dimstyle.
When I have a text like this…


and I change it to this…

I need to realign the text.

What would be the best strategy to do that? Or am I missing an option that would make my life easier…

Thanks,
T.

HI @tobias.stoltmann , as far as aligning is concerned, you could use the plane property of TextEntity.

For example

TextEntity textEntity = new TextEntity();
Plane pl = Plane.WorldXY;
pl.Translate(pl.YAxis * -10);
textEntity.Plane = pl;
1 Like

thanks @Darryl_Menezes.
But how will I determine the translation vector from the one plane to the other?

Ah, I got that, I guess.
E.g. I could get the bounding box and then get the relation inbetween those.
I will try and report.

Well, it depends on what you are using as inputs (or any criteria) for placing those texts.

@Darryl_Menezes
this is the solution I implementd:

is_horizontalmatch = target_style.TextHorizontalAlignment == entity.TextHorizontalAlignment
is_verticalmatch = target_style.TextVerticalAlignment == entity.TextVerticalAlignment

if is_horizontalmatch == False or is_verticalmatch == False:
    #Match the existing text to font and height to receive the correct geometric data
    entity.Font = target_style.Font
    entity.TextHeight = target_style.TextHeight
    entity_point = entity.GetBoundingBox(entity.Plane).Center

    entity.DimensionStyleId = target_style.Id
    future_center = entity.GetBoundingBox(entity.Plane).Center
    vector = entity_point - future_center
    plane = entity.Plane
    plane.Translate(vector)
    entity.Plane = plane

else:
    entity.DimensionStyleId = target_style.Id

Oh sorry i misunderstood your question. You could directly assign the TextVerticalAlignment, and TextHorizontalAlignment properties of your DimensionStyle to to your target alignment. And then you are anyways assigning the dimension style id to your text entity,
so entity.DImensionStyleId = targetstyle.Id should be enough