Data Exchange サンプル:ドア数量拾い

A woman analyzing a colorful 3D model on a transparent screen, with visualizations of data flow, alongside a graphic featuring the text 'Data Exchange' and a workflow description for a sample project.

Data Exchange サンプル:事前準備 の内容に沿って、GitHub – autodesk-platform-services/aps-dx-samples-nodejs  リポジトリが Windows ローカル環境にクローン・セットアップ済で実行出来ることを前提に、Quantity Takeoff for Doors(ドアの数量拾い)の内容を処理して、窓の拾い出しを目的に、「ドア」カテゴリ名でフィルタリングされたすべてのエンティティを取得します。なお、Data Exchange API は、現時点(2023 年 9 月)で Beta 版の API になっています。今後、手順や内容が変更される可能性があります。


はじめに

Data Exchange API を使って粒状データでデータ交換する際には、Autodesk Construction Cloud に作成した Exchange Item の ID を取得する必要があります。このタスクでは、Hub、Project、Folder をナビゲートし、Exchange Item を識別するために必要な Data Exchange GraphQL API の処理に焦点を当てています。

  • Hub、Project、Folder、Item、Version は、Autodesk Construction Cloud のドキュメント層である Autodesk Docs が持つ論理構造を識別するオブジェクト単位です。各オブジェクトは一意な ID を持ち、Data Management API を使ったアクセスの際にも使用します。ただし、使用される ID は、Hub を除いて Data Exchange API と Data Management API では形式が異なります。
  • 下記の Step 1 ~ Step 6 の手順を実行するには、Data Exchange サンプル:事前準備 でご紹介した手順でセットアップしたサンプルを起動して、「Quantity takeoff for Doors Sample Workflow」の [Go to sample] をクリックしてください。
Screenshot of Autodesk Platform Services Data Exchange Explorer Samples, featuring workflows for getting exchange item information and quantity takeoff for doors, with 'Go to sample' buttons.

Step 1:すべての Hub を取得する

ページ右上の [Login] ボタンをクリックして、Autodesk Construction Cloud のアクセス権を持つオートデスク アカウント(Autodesk ID)でログイン(サインイン)後、[List Hubs] をクリックします。画面に Hub ID が表示されるのでデータ交換(Data Exchange)を作成したプロジェクトがある Hub ID(”id” の値)を書き留めておきます。

Hub 一覧には、A360 や Fusion Team の Hub に加え、他者から招待されたプロジェクトの Hub が含まれます。Autodesk Construction Cloud の Hub は、ID の先頭文字が “b.” で始まります。もし、判別が難しい場合には、Autodesk Construction Cloud と APS 統合で必要なカスタム統合 でカスタム統合した際に、9. の「BIM 360 のアカウント ID」が、”b.” を除いた値を目安に判断をしてください。

  • 本サンプルの実行で使用している Client Id をカスタム統合していない場合には、Autodesk Construction Cloud の Hub は表示されません。ご注意ください。
Screenshot of the Autodesk Data Exchange Explorer interface displaying the workflow for quantity takeoff for doors, with a list of hubs, projects, and project folders, highlighted section showing 'Developer Advocacy Support'.

使用した GraphQL クエリ:

      {
        hubs {
            results {
                    name
                    id
            }
        }
      }

Step 2:すべての Project を取得する

Step 1 で の Hub ID を「Step 2: List project for a hub」下のテキストボックスに入力して、Hub 配下にある全 Project を取得します。[List Projects] をクリックして、Revit から Data Connector でデータ交換(Data Exchange)を作成したプロジェクト フォルダがある Project ID(”id” の値)を書き留めておきます。(下図では Toshiaki-ACC-Project-0 プロジェクト)

  • このクエリで返されるのは、プロジェクト管理者が「割り当てられた製品と権限」に Docs が割り当てられている場合です。また、アーカイブされたプロジェクトは返されません。
Screenshot of Autodesk Platform Services interface displaying steps for data exchange, including options to list hubs, projects, and project folders.

使用した GraphQL クエリ:

      {
        projects (hubId: "${hubId}") {
            results {
                name
                id
            }
        }
      }

Step 3:Project フォルダ(Folder)一覧を取得する

Step 2 で 書き留めた Project ID を「Step 3: List Project Folders」下のテキストボックスに入力して、Project 直下の Folder を取得します。[List Project Folders ] をクリックして、Revit から Data Connector でデータ交換(Data Exchange)を作成したプロジェクト フォルダ(下図では Test フォルダ)の ID(”id” の値)を書き留めます。

Screenshot of Autodesk Platform Services interface showing Data Exchange Explorer Sample Workflow for Doors, with steps to list hubs, projects, and folders.

使用した GraphQL クエリ:

    {
      project(projectId: "${projectId}") {
        id
        name
        folders {
          results {
            id
            name
            __typename
   
            folders {
                results {
                    id
                    name
                    __typename
                }
            }
            exchanges {
                results {
                    id
                    name
                    __typename
                }
            }
          }
        }
      }
    }

注:このリクエストのレスポンスには、Project 内の Folder  と Exchange が含まれています。

Step 4:Folder 内のコンテンツ一覧を取得する

Step 3 で 書き留めた Folder ID を「Step 4: List Folder content」下のテキストボックスに入力して、[List Folder Content] をクリックし、表示されるレスポンスからデータ交換(Data Exchange)の  Exchange ID(”id” の値)を書き留めます。

Screenshot of Autodesk Platform Services interface showing Data Exchange Explorer Sample Workflow for door quantity takeoff with various project options and JSON data structure.

使用した GraphQL クエリ:

    {
      folder(folderId: "${folderId}") {
        id
        name
        folders {
          results {
            id
            name
            __typename
          }
        }
        exchanges {
          results {
            id
            name
            alternativeRepresentations {
              fileUrn
              fileVersionUrn
            }
            __typename
          }
        }
      }
    }

Step 5:Exchange 情報を取得する

Step 4 で取得した Exchange ID を「Step 5: Get Exchange info by ID」下のテキストボックスに入力して、Data Exchange のプロパティを取得出来ることを確認します。[Get Exchange Information] をクリックしてください。

Screenshot of Autodesk Platform Services interface displaying data exchange workflow for quantity takeoff related to doors.

使用した GraphQL クエリ:

  {
    exchange(exchangeId: "${exchangeId}") {
      id
      name
      version {
        versionNumber
      }
      alternativeRepresentations {
        fileUrn
        fileVersionUrn
      }
      lineage {
        versions {
          results {
            id
            versionNumber
            createdOn
          }
        }
        tipVersion {
          versionNumber
        }
      }
      propertyDefinitions {
          results {
              id
              name
              specification
        }
      }
    }
  }

Step 6:数量拾いを作成する

Step 5 で取得した Exchange ID を「Step 6: List the exchanged data based on Category」直下のテキストボックスに入力、また、その下の 2 つめのテキストボックスにカテゴリ名「ドア」と入力して、[Generate quantity takeoff] をクリックしてください。

Screenshot of Autodesk Platform Services interface displaying Data Exchange Explorer Sample Workflow for quantity takeoff of doors, showing various project folders and exchange information steps.

使用した GraphQL クエリ:

    {
      exchange(exchangeId: "${exchangeId}") {
        id
        name
        version {
          versionNumber
        }
        elements(filter: {query: "property.name.category=='${category}'"}) {
          results {
            id
            name
            properties {
              results {
                name
                value
                propertyDefinition {
                  description
                  specification
                  units
                }
              }
            }
          }
        }
      }
    }

サンプルで使用される実際の GparhQL は、https://github.com/autodesk-platform-services/aps-dx-samples-nodejs/blob/main/services/aps/dx.js で参照することが出来ます。なお、Code Sample の内容の公開後、一部仕様が変更されたため、Step 5 と Step 6  に載された GraphQL 内のフィールド名が異なっています。(リポジトリ内の GraphQL 記述が更新されています。)

By Toshiaki Isezaki

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading