0
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
で動作しない場所でソート複数のテキスト要素のいずれかであるか、あるいは正当化ポイントがの途中または末尾にあるそれはですので、テキストを移動オブジェクト。コードオプションは、私がやりたいと思っています何のTextElement
Revitバージョンは2016
、しかしでそのポイントの値にアクセスするための直接的な方法はない:あなたは代わりに、テキストのバウンディングボックスを照会することができますあなたのモデルに既に入っているテキスト。 – KeachyPeenReturns
さらに、バウンディングボックスを使用する必要がある場合は、9つの可能なポイントのどれが私の実際のジャスティフィケーションポイントを表すかを判断するコードを含む必要があります。最高に畳んでいる。 – KeachyPeenReturns