General Discussions
Shape Formulas: getting a fill and text color by a reference item

Hi,

I want to use the formula to set the shape.fill property depending on a named shape on my drawing.

The goal is to quickly modify the fill of many elements in the drawing by defining a new color to an item with the name "alpha",

My idea was to do this ...

var shapeDefinition = $.shape('alpha');

if(shapeDefinition != null )
    {
        this.fill = shapeDefinition.fill;
    }
else
    {
        this.fill = 0;
    }

But that is not saveable in the formula field. There is neither an error message nor a status message.

Hi, I want to use the formula to set the shape.fill property depending on a named shape on my drawing. The goal is to quickly modify the fill of many elements in the drawing by defining a new color to an item with the name "alpha", My idea was to do this ... ```` var shapeDefinition = $.shape('alpha'); if(shapeDefinition != null ) { this.fill = shapeDefinition.fill; } else { this.fill = 0; } ```` But that is not saveable in the formula field. There is neither an error message nor a status message.

Hi Andreas,

Thanks for reaching out to us.

In order to achieve your goal, please ensure you have a shape named as "alpha". Based on the API, in order to get the shape's fill, you will need to use .fill() function. Please refer to here. So your codes in the fill property formula will be:

if ($.shape('alpha') !== null ) { 
    $.shape('alpha').fill(); //we will need a fill value for this field.
}

However, we are able to save your codes into the formula but it is not running due to the syntax error. If you want to check if your codes is running, you could press F12 to open the developer tool, then go to Console tab and check if there is any error after saving the codes.

Hope that helps.

Regards,
The Vecta Support Team

Hi Andreas, Thanks for reaching out to us. In order to achieve your goal, please ensure you have a shape named as "alpha". Based on the API, in order to get the shape's fill, you will need to use .fill() function. Please refer to [here](https://vecta.io/api/Vecta.Shape.php#.fill). So your codes in the fill property formula will be: ```` if ($.shape('alpha') !== null ) { $.shape('alpha').fill(); //we will need a fill value for this field. } ```` However, we are able to save your codes into the formula but it is not running due to the syntax error. If you want to check if your codes is running, you could press F12 to open the developer tool, then go to Console tab and check if there is any error after saving the codes. Hope that helps. Regards, The Vecta Support Team
22
1
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft