Solved

Extension APIs for blocks containers

  • 25 April 2024
  • 7 replies
  • 55 views

Badge +1

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?

icon

Best answer by Connor B101 26 April 2024, 17:05

View original

Comments

Userlevel 5
Badge +7

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

 

Badge +1

Hello @Humas1985 ,

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

Userlevel 5
Badge +7

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.

Userlevel 5
Badge +7

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

Userlevel 3
Badge +7

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? 

Userlevel 1
Badge

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!

Badge +1

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

Reply