Text note origin

Hello, Do anyone have an idea of how to get the text note origin point instead of the coord point? The coord point gives me the top right corner of the text note and I want to get the centroid of the text. Any ideas?

hi

def midletxtnote(t)
{
box=Revit.Element.BoundingBox(t);
p=Point.ByCoordinates(
0.5*(box.MinPoint.X+box.MaxPoint.X),
0.5*(box.MinPoint.Y+box.MaxPoint.Y),
0.5*(box.MinPoint.Z+box.MaxPoint.Z)
);
return p;
};

cordially
christian.stan

Thabk u.. Do u know how to get it theough Revit Api? As I want it at the middle of the script and I dont want to switch between dynamo and revit api.
I tried to follow the same way using Revit api and get the bounding box but it gives null.

here is

import sys
import clr
clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

def midletxtnote(t):
    tt=UnwrapElement(t)
    doc=tt.Document
    bb=tt.get_BoundingBox(doc.ActiveView)
    p=XYZ(0.5*(bb.Min.X+bb.Max.X),0.5*(bb.Min.Y+bb.Max.Y),0.5*(bb.Min.Z+bb.Max.Z))
    return p.ToPoint()


OUT = midletxtnote(IN[0])

cordially
christian.stan

Thank yooou!
I have already tried this mehod and it gave me null but i thought, maybe it needs doc.regenerate() after creating the textnote in my script and now, it gives me a value.
You really helped. Thank you!