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?
3 posts - 2 participants