I'll try to give it a shot:
Here's the method that creates actual MText:
Public Shared Sub BuildingTextArea()
Using m_Entity As New Building
Dim m_ObjectIds As ObjectId() = AutodeskFeatureFactory.GetEntity(m_Entity.ElementName)
If m_ObjectIds.Length > 0 Then
m_Entity.SaveSystemVariables()
Using m_ProgressBar As New AcUtProgressBar("Processing...", m_ObjectIds.Length)
Dim m_Text As New AcText(m_Entity.Database, m_Entity.Transaction)
m_Text.Layer.Name = m_Entity.Layer.Name + "_ANNOTATION"
Try
For Each m_ObjectId As ObjectId In m_ObjectIds
m_Entity.ObjectId = m_ObjectId
m_Text.Contents = _
"P=" + _
AutodeskFeatureFactory.GetAttributeValue(m_ObjectId, m_Entity.ElementName, "FootprintSurface").ToString + _
"m\U+00B2"
m_Text.Height = 1
m_Text.Location = m_Entity.Centroid <<<============ Here it is
m_Text.ParentId = m_ObjectId
m_Text.Insert()
Next
m_Entity.TransactionCommit()
Finally
m_Entity.TransactionDispose()
End Try
End Using
m_Entity.RestoreSystemVariables()
Else
AcUtEditor.WriteMessage("No entities.")
End If
End Using
End Sub
=========================
Now to the AcGeMPolygon class and it's Centroid property:
Public ReadOnly Property Centroid() As Point3d
Get
Dim m_Result As Point3d
Dim m_MPolygon As MPolygon = Me.GetEntityForRead
If m_MPolygon IsNot Nothing Then
Using AGF As New AutodeskGeometryFactory(Me.Database, Me.Transaction)
Dim m_MPolygonLoop As MPolygonLoop = m_MPolygon.GetMPolygonLoopAt(0)
Dim m_Point2dCollection As New Point2dCollection
For Each m_BulgeVertex As BulgeVertex In m_MPolygonLoop
m_Point2dCollection.Add(m_BulgeVertex.Vertex)
Next
Dim m_MultiPoint As MultiPoint = AGF.CreateMultiPoint(m_Point2dCollection)
Dim m_LinearRing As New LinearRing(m_MultiPoint.Coordinates)
m_Result = AGF.CreateAcGePoint3d(m_LinearRing.Centroid) <<<============== See below...
End Using
End If
Return m_Result
End Get
End Property
=========================
Now to the AutodeskGeometryFactory method that actually instantiates Point3D
Public Function CreateAcGePoint3d(ByVal point As Point) As Point3d
Return New Point3d(point.X, point.Y, point.Z)
End Function
=========================
What for a simple MText example...