Skip to main content
Apr 25, 2024 8:36 AM UTC
Solved

Extension APIs for blocks containers

Hello,

I have a use case in LucidCharts where I need to identify if a block area is contained in another.

In the documentation you can find this method getContainers() but it returns empty array for nested blocks. Those blocks seem to have valid bounding box values as well.

Is there a correct way to use that API?

Connor B
Connor BAnswer
Lucid product team
Apr 26, 2024 3:05 PM UTC

Hey @KVG!

After looking into this in depth, it looks like the getContainers() method will only return containers (swim lanes, frames, etc.) that surround the block, instead of nested blocks. To circumvent this, I would recommend using the getBoundingBox() method as well as the isBoxWithin() helper method to determine if a block resides within another.

 

Happy to answer any other questions that come up!

Comments

Humas1985
Lucid Legend Level 10
Lucid Legend Level 10
Apr 25, 2024 11:44 AM UTC

Hi @KGV 

 

Directly navigate through or restore specific versions via Lucidchart's API is not possible. 

You have to try other possibilities as well as here is the help article related to API methods - https://developer.lucid.co/
 

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

 

Translate
Huma || Lucid Legend
KGVAuthor
Apr 25, 2024 12:02 PM UTC

Hello @Humas1985 ,

I think you meant to address another question with the answer. Can you support with this question scope about block containers?

Translate
Humas1985
Lucid Legend Level 10
Lucid Legend Level 10
Apr 25, 2024 12:10 PM UTC

Hi @KGV - Regret for the inconvenience caused, yes it was prepared for a different use case - let me look into your use case and will get back to you in a bit.

Translate
Huma || Lucid Legend
Humas1985
Lucid Legend Level 10
Lucid Legend Level 10
Apr 25, 2024 1:47 PM UTC

Hi @KGV 

Per your finding on the getContainers() method in Lucid have limitations with nested blocks.

We should try other possibilities like - Iterative Traversal with Bounding Boxes or Custom Logic based on Parent-Child Relationships

 

We will also take some right direction from the team here.

 

CC: @Addie - Could you please take this use case for @KGV .

 

Regards

Translate
Huma || Lucid Legend
Richard Udell
Lucid support team
Apr 25, 2024 9:49 PM UTC

Thank you for your question @KGV! Also, thank you for your contributions @Humas1985, Addie and I always appreciate your work in the Lucid Community. 

 

@KGV we are happy to take a closer look at your use case and see why you could be getting an empty array. Can you please share a screenshot of your document (showing the nested blocks) along with your code snippet using the getContainers() method? 

Translate
Connor B
Connor BAnswer
Lucid product team
Apr 26, 2024 3:05 PM UTC

Hey @KVG!

After looking into this in depth, it looks like the getContainers() method will only return containers (swim lanes, frames, etc.) that surround the block, instead of nested blocks. To circumvent this, I would recommend using the getBoundingBox() method as well as the isBoxWithin() helper method to determine if a block resides within another.

 

Happy to answer any other questions that come up!

Translate
KGVAuthor
Apr 29, 2024 9:25 AM UTC

Hello @Connor B101 , I used the suggested workaround, and it works fine as a replacement to what I am trying to do with method getContainers() But I will need to add extra logic/structures that might be a bit expensive if the diagram contains big number of blocks/elements, which might consume longer time to process, and it would be ideal if the getContainers() method is extended to the documentation scope. I will use the isBoxWithin() for now.

Thank you

Translate