Book a Demo

Author Topic: Add in: get stereotype  (Read 8609 times)

Hurra

  • EA User
  • **
  • Posts: 184
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Add in: get stereotype
« on: September 20, 2016, 04:49:10 pm »
Hello!

A few weeks ago a saw a post on this forum on how it is possible to create a add-in to allow shape scripts such as

Code: [Select]
decoration symbol {
    orientation = "SE";
Image("#STEREOTYPE#.emf",0,0,100,100);
}

However, I didn't know anything about creating add-ins and had to read up on that. Now I can't find the post regarding that add-in. I have searched this forum and googled like crazy...

Can someone help me with this topic or refer me to that forum post?

Thank you,

Robert.
always learning!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add in: get stereotype
« Reply #1 on: September 20, 2016, 06:37:58 pm »
Hmm, weird. Usually you write a shape script for a certain stereotype and as such the script knows which stereotype is present, so #STEREOTYPE# as tag look strange.

You can use
Code: [Select]
print("#addin:myAddIn,pFunc1#") to call the operation pFunc in your add-in myAddIn and pass the parameter pFunc1 (and possibly others with comma separated after that).

q.

Hurra

  • EA User
  • **
  • Posts: 184
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Add in: get stereotype
« Reply #2 on: September 20, 2016, 09:31:57 pm »
Thank you for your answer.

I have tried this in my add-in:

Code: [Select]
public string GetValueForStereotype(EA.Repository rep, string eaGuid, object stereotype)
        {
            EA.Element element = rep.GetElementByGuid(eaGuid);
            string ret = element.Stereotype;
            return ret;
        }

and shape script
Code: [Select]
decoration symbol {
    orientation = "SE";
Image("Mall::#ADDIN:GetStereotype, GetValueForStereotype#.emf",0,0,100,100);
}

where Mall i the name on my technology.

I have tried to print #ADDIN:GetStereotype, GetValueForStereotype# which gives me the correct output, but no image is shown.

Thanks for your time.
always learning!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add in: get stereotype
« Reply #3 on: September 20, 2016, 11:08:38 pm »
I'm pretty sure this expansion is only done in the print statement and not generally in string expansion. Could any Sparxian affirm that?

q.

Hurra

  • EA User
  • **
  • Posts: 184
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Add in: get stereotype
« Reply #4 on: September 21, 2016, 12:32:53 am »
I'm pretty sure this expansion is only done in the print statement and not generally in string expansion. Could any Sparxian affirm that?

q.

I'm sorry, I don't think I understand what you mean..

As I said, I read in a thread that this would be possible with an add-in. Is that statement false?

Thanks!
always learning!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add in: get stereotype
« Reply #5 on: September 21, 2016, 12:37:35 am »
I assume than this assumption is false (but have no real proof). All I can say is that it works with a print statement. But I doubt that string replacement is done in Image operation before being interpreted. You might write a support request if none of the Sparxian answers here in reasonable time.

q.

Hurra

  • EA User
  • **
  • Posts: 184
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Add in: get stereotype
« Reply #6 on: September 21, 2016, 12:58:53 am »
I assume than this assumption is false (but have no real proof). All I can say is that it works with a print statement. But I doubt that string replacement is done in Image operation before being interpreted. You might write a support request if none of the Sparxian answers here in reasonable time.

q.

Ok, thank you!

I will wait until the end of the week before writing a support request.

Cheers!
always learning!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Add in: get stereotype
« Reply #7 on: September 21, 2016, 08:44:30 am »
Yes, substitutions are only done for print commands and conditions.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add in: get stereotype
« Reply #8 on: September 21, 2016, 09:36:24 am »
I guess sending a feature request won't hurt. The substitution is already there (for the print). So the only thing needed is to apply it to other strings like in the Image operation. (Of course I don't know the programming details. It's only an assumption.)

On the short term you'd need to think of other ways to achieve what you want.

q.