1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【UiPath】IXPの抽出オブジェクトからハイライトする座標位置を取得する

1
Last updated at Posted at 2026-01-29

はじめに

  • 本記事は、IXP(Intelligent Xtraction and Processing / マルチモーダルなデータ抽出機能)の出力オブジェクト(ドキュメントデータ)からハイライトの座標情報を取得する方法を扱います。
  • 扱うドキュメントの種類:非構造化ドキュメントと複雑なドキュメント
  • 記事の内容は、個人の見解または確認結果であり、UiPath の公式見解ではありません。
  • 製品仕様や参考画像は2026年1月28日時点(先行環境)のもので構成しています。

IXPの出力は「IDocumentData(UiPath.IntelligentOCR.StudioWeb.Activities.SWEntities.ExtendedExtractionResultsForDocumentData.GptIxpXX.Bundle.GptIxpXX)」型のオブジェクトです。
※クラシックDUの出力オブジェクト(ExtractionResult)も内包しています。

中身を確認したい方は「テキスト ファイルに書き込み」などで以下を出力してください。
Newtonsoft.Json.JsonConvert.SerializeObject(DocumentData)

目次

## ExtractionResult はどこにある?
## ハイライト(参照位置)情報の取り方(繰り返しアクティビティ)
## ハイライト(参照位置)情報の取り方(コード化されたワークフロー)

ExtractionResult はどこにある?

「ドキュメントデータ」オブジェクトはクラシックDU時代のExtractionResultより簡単に値を取得できます。

(値取得の記述例)
 ドキュメントデータ.Data.請求書フィールド

DocumentDataから値取得.png

ただし、上記で取得できるのは「信頼度」とフィールドの「値」のみです。

DocumentDataから値取得2.png

検証ステーションなどで目にするハイライト処理で利用する参照元の情報(参照文字列および座標位置)はどこから取得できる?
クラシックDUで開発された方ならExtractionResult型が恋しくなりますよね。
大丈夫です!ドキュメントデータはExtractionResultも保持しています。
こちらです↓↓

ドキュメントデータ.Properties.ExtractionResult

なお、デジタル化の出力(ドキュメントテキストとDOM)は以下で取得できます↓↓

ドキュメントテキスト:
ドキュメントデータ.DocumentMetadata.Text
DOM:
ドキュメントデータ.DocumentMetadata.DocumentObjectModel

ハイライト(参照位置)情報の取り方(繰り返しアクティビティ)

IXPはタクソノミーのフィールド定義に『フィールドグループ』が追加された、かつ、いずれも表形式でフィールドデータを保持するために、ExtractionResultのかなり深い場所に参照位置情報を持っています。

(イメージ)
DocumentDataから値取得3.png
・・・ 以降、省略

  1. 繰り返し(コレクションの各要素)入力:抽出結果オブジェクト.ResultsDocument.Fields → currentResultsDataPoint
  2. 繰り返し(コレクションの各要素)入力:currentResultsDataPoint.Values → currentResultsValue
  3. 繰り返し(コレクションの各要素)入力:currentResultsValue.Components → currentResultsDataPoint
  4. 繰り返し(コレクションの各要素)入力:currentResultsDataPoint.Values → currentResultsValue
  5. 繰り返し(コレクションの各要素)入力:currentResultsValue.Components → currentResultsDataPoint
  6. 繰り返し(コレクションの各要素)入力:currentResultsDataPoint.Values → currentResultsValue
  7. if文(currentResultsValue.Reference.Tokens.Count > 0)
  8. 繰り返し(コレクションの各要素)入力:currentResultsValue.Reference.Tokens → currentResultsValueTokens
  9. 繰り返し(コレクションの各要素)入力:currentResultsValueTokens.Boxes → currentBox
  10. 値取得(例)"Field Name:"+currentResultsDataPoint.FieldName+" Value:"+currentResultsValue.Value+" Height:"+currentBox.Height.ToString+" Width:"+currentBox.Width.ToString+" Left:"+currentBox.Left.ToString+" Top:"+currentBox.Top.ToString

ハイライト(参照位置)情報の取り方(コード化されたワークフロー)

繰り返しアクティビティでつくるとネストが深くなりすぎるので、コード化されたワークフローでの実装イメージを以下に記載します。

using IXPタ抽出.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.DocumentProcessing.Contracts.Results;


namespace IXPタ抽出
{
    public class ハイライト情報の抽出 : CodedWorkflow
    {
        [Workflow]
        public void Execute(ExtractionResult docData)
        {
            // To start using services, use IntelliSense (CTRL + Space) to discover the available services:
            // e.g. system.GetAsset(...)

            // For accessing UI Elements from Object Repository, you can use the Descriptors class e.g:
            // var screen = uiAutomation.Open(Descriptors.MyApp.FirstScreen);
            // screen.Click(Descriptors.MyApp.FirstScreen.SettingsButton);

            ResultsDataPoint [] points = docData.ResultsDocument.Fields;
            foreach (ResultsDataPoint point in points)
            {
                if (point.Values == null)
                {
                    continue;
                }
                    
                foreach (ResultsValue pgroup1 in point.Values)
                {
                    foreach (ResultsDataPoint point2 in pgroup1.Components)
                    {
                        foreach (ResultsValue pgroup2 in point2.Values)
                        {
                            foreach (ResultsDataPoint point3 in pgroup2.Components)
                            {
                                foreach (ResultsValue pgroup3 in point3.Values)
                                {
                                    string fieldName = point3.FieldName;
                                    foreach (ResultsValueTokens token in pgroup3.Reference.Tokens)
                                    {
                                        // 座標情報の取得
                                        double rectX = token.Boxes[0].Left;
                                        double rectY = token.Boxes[0].Top;
                                        double rectWidth = token.Boxes[0].Width;
                                        double rectHeight = token.Boxes[0].Height;
                                        Console.WriteLine(fieldName+" Left:"+rectX+" Top:"+rectY+" Width:"+rectWidth+" Height:"+rectHeight);
                                    }
                                }
                            }    
                        }    
                    }
                }
            }
        }
    }
}

さいごに

いかがでしたでしょうか。
従来モデルのExtractionResultと比べると大分深いところにデータを持つので
最初ひっぱり出すとき結構苦労しました。
検証ステーションを使わないで画像にハイライト情報を付与したいみたいなニッチなケースでしか役立ちませんがメモしときます。
最後までお読みいただきありがとうございます(-ω-)/

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?