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?

# ChangeLensアドイン改善版:差分検出の精度向上とコード整理

Last updated at Posted at 2025-08-22

はじめに

前回公開したChangeLensアドインは、Revitモデルの差分検出を簡単に行えるツールとして公開しました。
今回の改善版では、以下の点を改善・追加しています。

改善版GitHubリンク
https://github.com/KengoTanaka-BIM/ChangeLens

前回の記事
https://qiita.com/KengoTanaka-BIM/items/0a54b51007f6b590fcc5

改善ポイント

  1. パラメータ変更判定の精度向上

    • 重要パラメータ(直径、幅、高さ、システムタイプなど)の変更を限定的に検出するように修正
    • 不要なパラメータ差分は無視することで、誤検出を減らしました
  2. 不要コードの整理

    • 前回は「タイプ一致だが位置違い」の要素を取得するコードがあったが未使用だったため削除
    • コード全体を見やすく整理
  3. 位置判定の精度向上

    • IsSameLocation メソッドで許容誤差を明示的に設定(約1インチ ≒ 0.0328フィート)
    • LocationPointLocationCurve の両方に対応
  4. Excel出力の改善

    • OpenXMLでシンプルにExcel出力
    • ヘッダ行とステータス(Added/Deleted/ParamModified)を明示的に出力
  5. UI・進捗対応

    • IProgress<int> に対応し、進捗バー表示が可能(大量要素でも途中経過が見える)

改善後の挙動

スクリーンショット 2025-08-22 175244.png
スクリーンショット 2025-08-22 175403.png

  • 追加された(又はジオメトリ変更)要素は赤
  • パラメータが変更された要素はオレンジ
  • 変更なし要素は色変更なし
  • 削除要素はExcelのみ記録

以前のバージョンで発生していた不必要な赤表示や誤検出も改善されています。

コード抜粋

重要パラメータ変更判定

private static bool IsParamChangedLimited(Element eNew, Element eOld)
{
    string[] importantParams = { "Diameter", "直径", "Height", "高さ", "Width", "幅", "System Type", "システムタイプ" };
    foreach (Parameter pNew in eNew.Parameters)
    {
        if (!importantParams.Contains(pNew.Definition.Name)) continue;
        Parameter pOld = eOld.LookupParameter(pNew.Definition.Name);
        if (pOld != null && !ParameterEquals(pNew, pOld))
            return true;
    }
    return false;
}

要素ハイライト

private static void SetElementColor(Element e, OverrideGraphicSettings ogs, Color color, Document doc)
{
    ogs.SetProjectionLineColor(color);
    ogs.SetSurfaceForegroundPatternColor(color);
    ogs.SetSurfaceForegroundPatternId(GetSolidFillPatternId(doc));
    e.Document.ActiveView.SetElementOverrides(e.Id, ogs);
}

まとめ

今回の改善版では、差分検出の精度向上とコードの整理を行い、より実務で使いやすいアドインになりました。
今後は「タイプ一致だが位置違い」要素の検出や、より複雑なパラメータ比較も追加予定です。

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?