1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Revit API】選択した要素のパラメータをCSVで一括出力するRevitアドイン【Revit2026対応】

Posted at

概要

このアドインは、Revitでユーザーが選択した要素のパラメータをCSVファイルにまとめて書き出すツールです。
選択した要素ごとに全パラメータの名前と値を取得し、Excelなどで簡単に管理・分析できる形式にします。

主な機能

  • 選択したRevit要素の全パラメータを取得
  • パラメータの型(数値、文字列、要素IDなど)に応じた適切な文字列変換
  • CSVファイルにエスケープ処理を行い安全に書き出し
  • 出力先はデスクトップ
  • パラメータの中身をExcelやテキストエディタで簡単に閲覧可能

使い方

  1. Revitでパラメータを取得したい要素を複数選択
  2. アドインを実行すると、保存先パスを自動で設定しCSVファイルを作成
  3. 完了後、ファイルの保存場所をダイアログで通知

コードのポイント

// 選択要素の取得
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
if (selectedIds.Count == 0)
{
    TaskDialog.Show("パラメータ出力", "要素を選択してください。");
    return Result.Cancelled;
}

// CSV出力の準備
var sb = new StringBuilder();
sb.AppendLine("ElementId,ParameterName,ParameterValue");

// パラメータの文字列変換はGetParameterValueで型ごとに処理
foreach (ElementId id in selectedIds)
{
    Element elem = doc.GetElement(id);
    foreach (Parameter param in elem.Parameters)
    {
        string paramName = param.Definition.Name;
        string paramValue = GetParameterValue(param);
        sb.AppendLine($"{elem.Id},{Escape(paramName)},{Escape(paramValue)}");
    }
}

// CSV書き出し(UTF-8)
File.WriteAllText(csvPath, sb.ToString(), Encoding.UTF8);
  • GetParameterValue メソッドでパラメータの型に合わせた文字列化を実施

  • Escape メソッドでCSV用に文字列をカンマや改行、ダブルクォーテーションを適切にエスケープ

今後の改善予定

  • UIで出力対象パラメータの選択・フィルタリング機能の追加
  • 複数選択ビューやシート単位でのまとめ出力対応
  • 出力ファイル名や保存先をユーザーが指定可能に
  • 出力フォーマットの柔軟化(ExcelやJSON対応など)

最後に

この「ElementParameterExporter2026」は、BIMモデリング作業や品質管理でのパラメータチェックに役立つツールです。
自分のプロジェクトに合わせてカスタマイズして使いやすくしてみてください。

興味があればGitHubで公開していますのでぜひご覧ください。

リポジトリリンク

ElementParameterExporter2026 - GitHub

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?