2017-06-01 9 views
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

答えて

0

はい、本当にありがとうございます。 TextBoxLocationプロパティを実装していません。 Locationプロパティは、単一点または曲線データのいずれかを提供できます。残念ながら、TextBoxの位置は、より複雑なもの、例えば、複数のポイントで表され、LocationCurveまたはLocationPointを使用して表現できません。したがって、テキスト要素に対しては何も返されません。私はあなたが最初の場所でのTextElementを作成するポイント値を提供する必要があり、それは不可解なことを見つける

http://thebuildingcoder.typepad.com/blog/2014/10/new-text-note-and-text-width-calculation.html

+0

、しかしでそのポイントの値にアクセスするための直接的な方法はない:あなたは代わりに、テキストのバウンディングボックスを照会することができますあなたのモデルに既に入っているテキスト。 – KeachyPeenReturns

+0

さらに、バウンディングボックスを使用する必要がある場合は、9つの可能なポイントのどれが私の実際のジャスティフィケーションポイントを表すかを判断するコードを含む必要があります。最高に畳んでいる。 – KeachyPeenReturns

関連する問題