Skip to main content

Hello,

I created a custom shape library with few of custom shapes with this method, and with Extension APIs I only can get some common predefined properties of the used shapes, none of them reflects the custom shape information like Library name or shape type! Is there a way to pragmatically identify/read the shape type a library inside a LucidChart plugin?

 

Note:

As a workaround for now, I used the textarea “name” property where I store some info of the shape itself so that I retrieve and identify the used shape, but it doesn’t look ideal for me!

{
"properties": t],
"style": {
"fill": { "type": 'color', "color": '#D7FAF55F', },
"stroke": { "color": '#808080', "width": 6 },
"rounding": 50,
},
"geometry": e
{
"type": "rect"
},
],
"textarea" : {
"name" : "customeLibrary000customShapeType",
"text" : "Specific Module",
"editable": true,
"style": { "color": "#0a0a0a" },
},
}

 

Hi @KGV 

You have made significant progress in creating custom shapes, but I spot the difficulty you're facing in programmatically identifying custom shape information.

The current limitations of Lucidchart's Extension APIs mean they primarily offer access to standard predefined properties, without direct support for retrieving custom shape details such as library name or shape type.

While your workaround utilizing the textarea "name" property showcases creative problem-solving, I accept that it may not be the most optimal solution, and we may need to explore other options to achieve your goals with Custom Metadata / Implement a naming convention for your shapes.

However – on the whole I would recommend this for an idea / feature request, at the same time we will wait to hear from other community members / associates to share their insight, on whether they have any suggestions that may better meet your needs.

 

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


@Richard U Can I get a proper answer to this question?  I wouldn’t consider it “answered” !


Hi KGV,

It sounds like you are trying to get the shape type or library to see which shapes have been used on a Lucid document, correct? Our REST API endpoint Get Document Contents returns information about the shapes on a document. The “class” property that is returned on each shape gives the shape type. Does this help solve the problem?


Hello @Trevor J ,

Is it possible to do the same for plugins Extension APIs? As far as I see the shape type is just “custom shape”


What I am trying to do is to create a plugin that analyses a design in Lucid Charts done with custom shapes. So the logic in that plugin will need to know which shapes are used and how they are connected in order to apply the relevant analysis .


You’re correct, I’m also only seeing “custom shape” as the shape type. I think there is a potential solution with through Extension APIs, but I have no definitive answers yet. I’m looking into this now and will get back to you once I’ve confirmed if it’s possible.


Thank you for your patience, KGV. We don’t currently have a clean way of obtaining this information about custom blocks, but one is coming soon. Expect another update within the next week.


@Trevor J great 🙂 , thanks for the updates, please let me know later what it is.


We’ve updated the Lucid extension SDK to have a fix for this. If you update your package to use version 0.0.323 or later, you should be able to use CustomBlockProxy’s method getCustomShapeType(). This returns a json object with “shape”, “library”, and “packageId” for any custom shapes. Here’s some sample code for how this can be used:

client.registerAction('getShapeInfo', () => {
for(const rpageId, page] of document.pages) {
for(const blockId, block] of page.blocks) {
if(block instanceof CustomBlockProxy) {
const shapeInfo = block.getCustomShapeType()
console.log('Found shape \"' + shapeInfo.shape + '\" of library \"' + shapeInfo.library + '\" from package \"' + shapeInfo.packageId + '\"');
} else
console.log('Found ' + block.getClassName());
}
}
});

menu.addMenuItem({
label: 'Get Custom Shape Info',
action: 'getShapeInfo',
menuType: MenuType.Main,
});

 


Reply