0

Revit Api 2012 c# でユーザーが入力した選択したオブジェクトのインスタンスを作成しようとしていますが、ElementTransformUtils.CopyElement への 3 番目の入力が新しい場所ではなく平行移動ベクトルであることを発見したので、要素から固定点を選択しようとしていますを選択し、そこから新しい場所の位置を減算し、結果を並進ベクトルとして配置します。問題は: pickobject.globalPoint を使用して、コードを実行するたびに変更される選択したオブジェクトからポイントを取得するので、質問: ユーザーが入力した要素を選択するたびに同じポイントを取得する方法は? 前もって感謝します

4

1 に答える 1

0

ここで説明されているように、元の要素を選択します:選択したオブジェクトのインスタンスを作成する Revit Api

次のように要素の場所を取得します。

Location location = originalElement.Location;

LocationPoint locationPoint = location as LocationPoint;

if (locationPoint != null)
{
  XYZ originalPoint = location.Point;
}

次のように、新しい要素の場所を選択します。

UIDocument uidoc = this.ActiveUIDocument;

XYZ newPoint = uidoc.Selection.PickPoint("Select a location for the element");

並進ベクトルを作成します。

XYZ translationVector = newPoint - originalPoint;

要素をコピーします。

Document doc = uidoc.Document;

ICollection<ElementId> copiedElementIds = ElementTransformUtils.CopyElement(doc, originalElement.Id, translationVector);

API ドキュメントによると、単一の ElementId ではなく ICollection が返される理由は、「依存関係のために複数の要素が作成される可能性がある」ためです。

于 2013-09-12T17:39:29.283 に答える