TextEntity.Style has no effect?

Hi All,

I’m trying to add some text to a document, and specify a text style upon creation, but for some reason, the style doesn’t seem to have any effect.

Here’s my code:

def InsertText(
    doc, Layer: str, Text: str, point: list, height: int, StyleName: str, bold: bool, italic: bool, **kwargs
):
    ob = doc.Objects
    rg = Rhino.Geometry
    rot = kwargs.get('rotation', None)  # OPTIONAL ROTATION ANGLE (DEG)
    plane = kwargs.get('Plane', None) # OPTIONAL PLANE - DEFAULT IS WORLD XY PLANE.
    Justification = kwargs.get('Justification', None)

    # INSERTION POINT ADDED AS LIST OF 2X COORDS - X AND Y ONLY.
    pt = rg.Point3d(point[0], point[1], 0.0)

    # DEFAULTS TO WorldXY plane
    if not plane:
        plane = rg.Plane.WorldXY
        plane.Origin = pt

    # # IF ROTATION WAS SPECIFIED:
    if rot:
         trans = rg.Transform.Rotation(Rhino.RhinoMath.ToRadians(rot),pt)
         plane.Transform(trans)
    if not rot:
         rot = 0

    txtEntity = rg.TextEntity()
    txtEntity.Text = str(Text)
    txtEntity.Plane = plane
    txtEntity.Style = doc.DimStyles.FindName(StyleName) # ***NO EFFECT***

    txt = ob.AddText(txtEntity)
    SetLayer(doc, txt, Layer)
    return txt

Any Suggestions?

Hi @Gerrard_Hickson,

Try using TextEntity.Create.

Here is a sample that uses the current dimension style and overrides the font.

test_arial_black_text.py (1.0 KB)

– Dale

Thanks - I tried that earlier, but was getting an error I couldn’t figure out. I realise now it was a silly mistake.