Hi All,
I’m trying to write a function that inserts text on a drawing, with an optional rotation value.
The problem is that there doesn’t seem to be an argument for rotation in the ‘AddText’ method, so I’m rotating the text independantly of the ‘AddText’ method.
but still, that doesn’t seem to work - I’m getting the error below.
Error: ‘TextObject’ object has no attribute ‘Transform’
Here’s my code:
def InsertText(
doc, Layer: str, Text: str, point: list, height: int, font: 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.
# INSERTION POINT ADDED AS LIST OF 2X COORDS - X AND Y ONLY.
pt = rg.Point3d(point[0], point[1], 0.0)
trans = rg.Transform.Rotation(Rhino.RhinoMath.ToRadians(90),pt)
# DEFAULTS TO WorldXY plane
if not plane:
plane = rg.Plane.WorldXY
plane.Origin = pt
txt = ob.AddText(str(Text), plane, height, font, False, False)
ob.FindId(txt).Transform(trans)
SetLayer(doc, txt, Layer)
return txt
What am I doing wrong here?