Skip to main content
Nov 8, 2024 9:56 PM UTC
Solved

How to extract the graphic relationship between shapes with API?

Hi Lucidchart developer community,

I would like to know how I can extract with API the relationship between these two shapes, ie:

 

The API call:

       curl -k --request GET \

            --url https://api.lucid.co/documents/34f5d3b8-560f-4657-a170-214418d1126c/contents \

            --header 'Lucid-Api-Version: 1' \

            --header 'accept: application/json' \

            --header 'authorization: Bearer key-<the_token>' \

 

The result (does not reflect inclusion relationship):

{

  "id": "34f5d3b8-560f-4657-a170-214418d1126c",

  "title": "simple",

  "product": "lucidchart",

  "pages": [

    {

      "id": "0_0",

      "title": "Page 1",

      "index": 0,

      "items": {

        "shapes": [

          {

            "id": "2gtp6vMI4Wka",

            "class": "ProcessBlock",

            "textAreas": [

              {

                "label": "Text",

                "text": "B"

              }

            ],

            "customData": [],

            "linkedData": []

          },

          {

            "id": "Ogtp.VdULkh8",

            "class": "ProcessBlock",

            "textAreas": [

              {

                "label": "Text",

                "text": "A"

              }

            ],

            "customData": [],

            "linkedData": []

          }

        ],

        "lines": [],

        "groups": [],

        "layers": []

      },

      "customData": [],

      "linkedData": []

    }

  ],

  "data": {

    "collections": []

  }

}

 

The question:

How can I determine if the shape A contains shape B? Or if not possible what are the alternative approaches?

 

Best regards,

Gaston

tobi
tobiAnswer
Lucid Legend Level 3
Nov 9, 2024 2:49 PM UTC

Hey @Gaston Acuse I tried the same. AFAIK you can’t relate them, as those elements are only ‘visually’ related “A contains B” but not structurally. The API exposes the latter only. 

So to fix this you need to connect both shapes somehow. One options is using a (white) line, the other is grouping. Once done, both infos are available on the API then allowing you to extract the relationship.  

 

Bonus:  use conditional formatting to spot shapes which are not connected/grouped yet.

Comments

Richard Udell
Lucid support team
Nov 8, 2024 10:08 PM UTC

Hi @Gaston Acuse , thank you for contributing to the Lucid for Developers Community. We will look into your question and get back to you.

Translate
tobi
Lucid Legend Level 3
tobiLucid Legend Level 3Answer
Lucid Legend Level 3
Nov 9, 2024 2:49 PM UTC

Hey @Gaston Acuse I tried the same. AFAIK you can’t relate them, as those elements are only ‘visually’ related “A contains B” but not structurally. The API exposes the latter only. 

So to fix this you need to connect both shapes somehow. One options is using a (white) line, the other is grouping. Once done, both infos are available on the API then allowing you to extract the relationship.  

 

Bonus:  use conditional formatting to spot shapes which are not connected/grouped yet.

Translate
Emma D
Lucid support team
Nov 11, 2024 8:09 AM UTC

Hey @tobi, thanks for your excellent input! Confirming you are correct- @Gaston Acuse, our Document Contents endpoint doesn’t return an object’s absolute location on the canvas, so you’ll need to use a line or grouping to be able to identify the relationship in the response.

Translate