Book a Demo

Author Topic: Evaluate "Show Stereotype Labels" diagram switch in shapescript  (Read 5616 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Evaluate "Show Stereotype Labels" diagram switch in shapescript
« on: December 04, 2020, 12:11:08 am »
What would be the secret sauce to get the setting of that diagram properties switch from within a shape script? I tried
Code: [Select]
if (HasProperty("ShowStereotypeLabels", "1")) {
print("bingo");
} else {
print("nope");
}
But that always prints "nope" (as I expected).

q.

P.S. Obviously diagram properties do not work on connectors >:-(
« Last Edit: December 04, 2020, 12:18:00 am by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Evaluate "Show Stereotype Labels" diagram switch in shapescript
« Reply #1 on: December 04, 2020, 12:22:59 am »
I don't think you can query the diagram settings directly.

The two examples that sort of do that use a different approach.
https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/example_scripts.html

For example it seems like the property packagepath will be empty if the corresponding option on the diagram is not checked.

Code: [Select]
              if (hasproperty ("packagepath", ""))
               {
               }
          else
               {
                    printwrapped ("(from #packagepath#)");
               }

I'm not sure if that will be the case with the property stereotype as well, but it's worth a try.
If not you might need to resort to an add-in call to find out if that setting is active.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Evaluate "Show Stereotype Labels" diagram switch in shapescript
« Reply #2 on: December 04, 2020, 12:35:52 am »
I just don't want to waste my time trying out things that are not documented. Despreately I tried "stereotypehidden" from the "guesscription" https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/displaying_element_properties.html
but that did not work either. (long sigh)

q.

P.S. I could highjack the Connector Notation which can be queried. But that just feels odd.
« Last Edit: December 04, 2020, 12:41:09 am by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Evaluate "Show Stereotype Labels" diagram switch in shapescript
« Reply #3 on: December 04, 2020, 12:44:19 am »
Hmm, that sounds like it should have done the trick, but who knows.

Maybe we should ask Sparx to property document all these properties.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Evaluate "Show Stereotype Labels" diagram switch in shapescript
« Reply #4 on: January 11, 2021, 08:47:18 am »
I just don't want to waste my time trying out things that are not documented.
Yet, that's exactly what you did when you tried 'ShowStereotypeLabels'. That doesn't appear in the documentation.

'StereotypeHidden' from the element list corresponds to the option on the Element page for 'Show Element Stereotypes'.
[/quote]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Evaluate "Show Stereotype Labels" diagram switch in shapescript
« Reply #5 on: January 11, 2021, 10:25:44 am »
So StereotypeHidden appears once in the "documentation". As a single word in no context within a list of other keywords.

In my understanding a Documentation explains things using the word in context and give it a meaning by describing it. Probably there is a fundamental misundestanding between Sparxians and us Earthlings about the meaning of Documentation?

q.

P.S. I tried StereotypeHidden with the top mentioned script. Still it prints nope in all cases. Does not surprise me.
« Last Edit: January 11, 2021, 10:31:47 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Evaluate "Show Stereotype Labels" diagram switch in shapescript
« Reply #6 on: January 11, 2021, 11:32:40 am »
P.S. I tried StereotypeHidden with the top mentioned script. Still it prints nope in all cases. Does not surprise me.
That's because you're checking against "1", not "true". Did you try printing the value of that property itself?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Evaluate "Show Stereotype Labels" diagram switch in shapescript
« Reply #7 on: January 11, 2021, 07:34:36 pm »
That's because it's not documented. How should one know a) what that keyword means and b) what it contains?

Checking for true works. So thanks for that!

q.