Book a Demo

Author Topic: Shapescript - Can I set the Label Bold via command?  (Read 4903 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Shapescript - Can I set the Label Bold via command?
« on: February 15, 2022, 07:31:36 pm »
Via the UI you can set the label colour and you can set the text to bold.  Within a shapescript, you can set the colour via setfontcolor(), but there doesn't seem to be a method to make the font bold.

Is there a method or is this another 80% solution?

TIA,
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: Shapescript - Can I set the Label Bold via command?
« Reply #1 on: February 15, 2022, 08:35:47 pm »
There should be (it's fairly recent, I'm not sure if I ever used that)

One of the shape attributes is bold

Quote
bold

string

Description: Set to True if you want all print commands in the current shape or sub-shape to be displayed in bold.

Valid values: True or False (default = False)

https://sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/shape_attributes.html

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shapescript - Can I set the Label Bold via command?
« Reply #2 on: February 15, 2022, 09:06:03 pm »
There should be (it's fairly recent, I'm not sure if I ever used that)

One of the shape attributes is bold

Quote
bold

string

Description: Set to True if you want all print commands in the current shape or sub-shape to be displayed in bold.

Valid values: True or False (default = False)

https://sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/shape_attributes.html

Geert
Thanks, Geert,

But the help suggests it's used in a sub-shape.  I'm dealing with shape Label, a first-class shape.  Also, it's an attribute (IIRC - they can be conditional), whereas I need a command to allow me to set/unset as required.  Still, I'll try tomorrow and report back.  If anyone can come up with a command, please feel free.

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: Shapescript - Can I set the Label Bold via command?
« Reply #3 on: February 15, 2022, 09:15:07 pm »
The help says "shape or sub-shape"

And since the label is a shape, it should respond to the attribute bold.

I agree that it might be difficult to set it conditionally.
I'm guessing EA won't respond when if you put the bold attribute inside an if statement.

Workaround that maybe works is to have two labels on the same location, one bold, and one regular.
And then you simply put the print statement inside an if statement.

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shapescript - Can I set the Label Bold via command?
« Reply #4 on: February 15, 2022, 11:52:58 pm »
The help says "shape or sub-shape"

And since the label is a shape, it should respond to the attribute bold.

I agree that it might be difficult to set it conditionally.
I'm guessing EA won't respond when if you put the bold attribute inside an if statement.

A workaround that maybe works is to have two labels on the same location, one bold, and one regular.
And then you simply put the print statement inside an if statement.

Geert
Yeah, that was my thought, but I'll wait till the morning after a (hopefully) good night's sleep.


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

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Shapescript - Can I set the Label Bold via command?
« Reply #5 on: February 17, 2022, 11:53:12 am »

[SNIP]
Workaround that maybe works is to have two labels on the same location, one bold, and one regular.
And then you simply put the print statement inside an if statement.

Geert
Not quite, Geert,
I needed to create two subshapes within the shape label and set the attributes accordingly and conditionalise the call as in:

Code: [Select]
if(hastag("BoldIt","True"))
{
   addsubshape("bolder",100,100);
} else
{
   addsubshape("notbold",100,100);
}
shape bolder
{
   bold=true;
   printwrapped("#Alias# b");
}
shape notbold
{
   bold=false;
   printwrapped("#Alias# n");
}

But there were some unwelcome side effects (in typical Sparxian design)!
You can no longer select the label and move it!  (Separate bug report to be submitted)
There are some weird interactions with setfontcolor and other components of the shape (separate bug report to be submitted also).

Oh well...
Paolo
« Last Edit: February 17, 2022, 11:55:17 am by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!