from cognite.client.data_classes.contextualization import FileReference
detect_job = client.diagrams.detect(
entities=[
{"userDefinedField": "21PT1017","ignoredField": "AA11"},
{"userDefinedField": "21PT1018"}],
search_field="userDefinedField",
partial_match=True,
min_tokens=2,
file_ids=[101],
file_external_ids=["Test1"],
file_references=[
FileReference(id=20, first_page=1, last_page=10),
FileReference(external_id="ext_20", first_page=11, last_page=20)
])
result = detect_job.result
print(result)
from cognite.client.data_classes.contextualization import ConnectionFlags, DiagramDetectConfig
config = DiagramDetectConfig(
remove_leading_zeros=True,
connection_flags=ConnectionFlags(
no_text_inbetween=True,
natural_reading_order=True,
)
)
job = client.diagrams.detect(entities=[{"name": "A1"}], file_id=123, config=config)
{
"items": [
{
"fileId": 1234,
"pageRange": {
"begin": 51,
"end": 100
}
}
],
"jobId": 123,
"status": "Queued",
"createdTime": 1730204346000,
"startTime": 1730204346000,
"statusTime": 1730204346000,
"errorMessage": null,
"searchField": "userDefinedField",
"partialMatch": false,
"minTokens": 2
}Required capabilities:
assetsAcl:READfilesAcl:READ
Detect annotations in engineering diagrams. Note: All users in a CDF project with assets read-all and files read access to the requested files can access data sent to this endpoint.
Supported input file mime_types are application/pdf, image/jpeg, image/png, image/tiff. Also note that the header of a successful response contains an X-Job-Token which allows to fetch the result of the
job at /context/diagram/detect/{jobId} without requiring ‘assetsAcl:READ’.
from cognite.client.data_classes.contextualization import FileReference
detect_job = client.diagrams.detect(
entities=[
{"userDefinedField": "21PT1017","ignoredField": "AA11"},
{"userDefinedField": "21PT1018"}],
search_field="userDefinedField",
partial_match=True,
min_tokens=2,
file_ids=[101],
file_external_ids=["Test1"],
file_references=[
FileReference(id=20, first_page=1, last_page=10),
FileReference(external_id="ext_20", first_page=11, last_page=20)
])
result = detect_job.result
print(result)
from cognite.client.data_classes.contextualization import ConnectionFlags, DiagramDetectConfig
config = DiagramDetectConfig(
remove_leading_zeros=True,
connection_flags=ConnectionFlags(
no_text_inbetween=True,
natural_reading_order=True,
)
)
job = client.diagrams.detect(entities=[{"name": "A1"}], file_id=123, config=config)
{
"items": [
{
"fileId": 1234,
"pageRange": {
"begin": 51,
"end": 100
}
}
],
"jobId": 123,
"status": "Queued",
"createdTime": 1730204346000,
"startTime": 1730204346000,
"statusTime": 1730204346000,
"errorMessage": null,
"searchField": "userDefinedField",
"partialMatch": false,
"minTokens": 2
}Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Files to run entity detection on.
1 - 50 elementsEither file id, external id or instance id, and optionally a page range. At most 50 pages can be queried.
Show child attributes
A list of entities to look for. For example, all the assets under a root node. The searchField determines the strings that identify the entities.
1 - 500000 elements[
{
"userDefinedField": "21PT1017",
"ignoredField": "AA11"
},
{
"userDefinedField": ["21PT1017-A", "21PT1017-B"]
}
]
This field determines the string to search for and to identify object entities.
"userDefinedField"
Allow partial (fuzzy) matching of entities in the engineering diagrams. Creates a match only when it is possible to do so unambiguously.
Each detected item must match the detected entity on at least this number of tokens. A token is a substring of consecutive letters or digits.
Success
Either file id, external id or instance id, and optionally a page range. At most 50 pages can be queried.
Show child attributes
Contextualization job ID.
123
The status of the job.
Queued, Running, Completed, Failed The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.
x >= 01730204346000
The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.
x >= 01730204346000
The number of milliseconds since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.
x >= 01730204346000
If the job failed, some more information about the error cause.
null
This field determines the string to search for and to identify object entities.
"userDefinedField"
Allow partial (fuzzy) matching of entities in the engineering diagrams. Creates a match only when it is possible to do so unambiguously.
Each detected item must match the detected entity on at least this number of tokens. A token is a substring of consecutive letters or digits.
Was this page helpful?