C# 位置和位置的代码选项;位置点don';不能在TextElement上工作

C# 位置和位置的代码选项;位置点don';不能在TextElement上工作,c#,revit-api,C#,Revit Api,我想做的是按位置对多个文本元素进行排序,或者移动文本,使其对齐点位于对象的中点或端点 Revit版本是2016是的。文本框未实现位置属性。Location属性可以提供单点或曲线数据。不幸的是,TextBox位置由更复杂的东西表示,例如,多个点,不能使用LocationCurve或LocationPoint来表示。因此,文本元素完全不返回任何内容。您可以改为查询文本边界框: 我发现,在创建TextElement时,首先必须提供一个点值,这一点很难理解,但在模型中已有的文本中,无法直接访问该点值。此

我想做的是按位置对多个文本元素进行排序,或者移动文本,使其对齐点位于对象的中点或端点


Revit版本是2016

是的。
文本框
未实现
位置
属性。
Location
属性可以提供单点或曲线数据。不幸的是,
TextBox
位置由更复杂的东西表示,例如,多个点,不能使用
LocationCurve
LocationPoint
来表示。因此,文本元素完全不返回任何内容。您可以改为查询文本边界框:


我发现,在创建TextElement时,首先必须提供一个点值,这一点很难理解,但在模型中已有的文本中,无法直接访问该点值。此外,如果我必须使用边界框,我还必须包含一系列代码,确定9个可能点中的哪一个代表我的实际对正点。充其量也令人费解。
The Revit API does not seem to have enabled certain aspects of either Location or LocationPoint with respect to TextElements.  When using the code below, the result is the error "Object reference not set to an instance of an object".  As noted with comments, it claims to get a Location, and also a LocationPoint, but there is nothing in the .Point.X (Y Z).  Note also that I am picking an actual TextElement in the first line.


    Reference One_Pick = uiDoc.Selection.PickObject(ObjectType.Element, "Select First Text");
    Id1 = One_Pick.ElementId;
    One_Pikt = uiDoc.Document.GetElement(One_Pick) as TextElement;
    Location One_Location = One_Pikt.Location;//does not fail;
    LocationPoint One_Pt = One_Location as LocationPoint;//does not fail;
    Double XX = One_Pt.Point.X; Double YY = One_Pt.Point.Y; Double ZZ = One_Pt.Point.Z;//fails setting XX