Book a Demo

Author Topic: Apply Shapescript with fill color AND customizable on diagram?  (Read 4973 times)

Jacob Vos

  • EA User
  • **
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Is there a way to set a fill color in a shapescript, but still allow users to change the fill color in a diagram?

This is my shapescript:

Code: [Select]
shape main

{
setfillcolor(255,128,128);
rectangle(0, 0, 100, 100);
    addsubshape("typecompartment", 100, 20);
addsubshape("namecompartment", 100, 20);
    addsubshape("notescompartment", 100, 60);

shape typecompartment
{
h_align = "center";
v_align = "center";
bold = "true";
rectangle(0, 0, 100, 100);
print("Datavalidatieregel #TAG:ConstraintID#");
}

shape namecompartment
    {
h_align = "center";
v_align = "center";
editableField = "name";
rectangle(0, 0, 100, 100);
printwrapped("#name#");
     }

    shape notescompartment
    {
h_align = "left";
editableField = "note";
println("");
printwrapped("{#notes#}");
    }
}

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Apply Shapescript with fill color AND customizable on diagram?
« Reply #1 on: April 07, 2020, 12:09:18 am »
No, but you can set the default color in the UML profile.

Set the default (or regular color?) color of a stereotype and make sure to save the appearance when saving as UML profile.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Apply Shapescript with fill color AND customizable on diagram?
« Reply #2 on: April 07, 2020, 02:37:40 am »
The default as Geert describes won't help here as you replace it unconditionally in your shape script. EA has a GetUserFillColor() but you can not find out whether a user has change the default. You would need an additional tag to use that user color rather than your pre-defined one.

Code: [Select]
shape main {
if (hasTag("user color", "true")) {
SetFillColor(GetUserFillColor());
} else {
SetFillColor(1, 2, 3);
}
Rectangle(0,0,100,100);
}

q.

Jacob Vos

  • EA User
  • **
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Re: Apply Shapescript with fill color AND customizable on diagram?
« Reply #3 on: April 15, 2020, 04:38:47 pm »
@qwerty: I adjusted the shapescript as suggested by you, but still the color is not adjustable. Do you have any idea why? I saved 'Color and Appearance' with the profile.

Jacob Vos

  • EA User
  • **
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Re: Apply Shapescript with fill color AND customizable on diagram?
« Reply #4 on: April 15, 2020, 05:17:29 pm »
I saved the profile without 'Color and Appearance', but still no result.

BTW: Whether I saved the profile with or without color: when I change the fill color for a drawn element, then the color of the element does not change, but when selecting such an element, the fill button (in menu 'Style') changes to the color that I tried to apply. So it looks that the color someway is applied, but is 'overwritten' by the other fill color.

Can this have something to do with the presence of subshapes?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Apply Shapescript with fill color AND customizable on diagram?
« Reply #5 on: April 15, 2020, 06:26:59 pm »
If you want to use the color and appearance from the profile you should not set any color in the shapescript.

That allows your elements to have a default color, but still be changeable by a user.

Geert

Jacob Vos

  • EA User
  • **
  • Posts: 108
  • Karma: +0/-0
    • View Profile
Re: Apply Shapescript with fill color AND customizable on diagram?
« Reply #6 on: April 15, 2020, 08:39:36 pm »
Thank you Geert, this was the solution.

(So setting on the stereotype the Default Appearance, no color in the shapescript, and at publishing the profile choosing to include 'Color and Appearance'.)