Book a Demo

Author Topic: MDG ShapeScript render class as a use case  (Read 4741 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
MDG ShapeScript render class as a use case
« on: January 06, 2022, 10:34:51 pm »
Hello,

I have a stereotyped class that I need to display as a Use Case (ellipse) based on a tagged value.
I can't get the element name to be printed in the middle.

I ran a test without the Tagged value condition which works:
Code: [Select]
shape main{
h_align = "center";
v_align = "center";
ellipse (0, 0, 100, 100);
print("#name#");
}

With the following ShapeScript, I'm getting the following error: Unexpected symbol h_align

Code: [Select]
shape main{
      if (HasTag('UC','true'))
{
h_align = "center";
v_align = "center";
ellipse (0, 0, 100, 100);
print("#name#");
}
else
{
DrawNativeShape();
}
}

I also tried the following but the label is still rendered in the top left corner.

Code: [Select]
shape main{
      if (HasTag('UC','true'))
{
ellipse (0, 0, 100, 100);
addsubshape("uclabel");
shape uclabel{
setorigin("CENTER",0,0);
print("#name#");
}
}
else
{
DrawNativeShape();
}
}





Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: MDG ShapeScript render class as a use case
« Reply #1 on: January 07, 2022, 12:19:58 am »
Hi Guillaume,

Try using shape Label  as in:
Code: [Select]
shape Label   //v2.2 29-Nov-2021   //@CENTER
{
   if(hasproperty("rectanglenotation","0"))   //label only in Icon Form
   {
      setorigin("CENTER",0,0);
      print ("#Name#");
    }
}      //Shape: Label   //@CENTER   
[code]


HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: MDG ShapeScript render class as a use case
« Reply #2 on: January 07, 2022, 12:23:15 am »
   h_align = "center";
   v_align = "center";


are only valid at the beginning of a (sub)shape

If you are happy with your main shape, you should be able to put that into a subshape, and add the subshape conditionally.
So something like (without testing)

Code: [Select]
shape main{
      if (HasTag('UC','true'))
{
addSubShape("useCase", 100, 100);
}
else
{
DrawNativeShape();
}
shape useCase
{
h_align = "center";
v_align = "center";
ellipse (0, 0, 100, 100);
print("#name#");
}
}

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: MDG ShapeScript render class as a use case
« Reply #3 on: January 07, 2022, 01:14:08 am »
Hi Geert and Paolo,

Thank you for your answers.
I used Geert's suggestion which works perfectly   :D

Cheers
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com