Book a Demo

Author Topic: two shape script questions  (Read 5351 times)

spelger

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
two shape script questions
« on: December 03, 2015, 04:29:21 am »
Hi,

i'm using shape script to customize a shape. i'd like to be able to bolden some text like EA does for a class object on a class diagram as an example.

also, when a class is defined in say Package1 and exists as a link on a diagram in Package2 EA will prefix the class name with the package name (scoping). how can that be done in shape script? to be clear, when the class defined in Package1 is on a diagram in Package1 i want the name of the class, but when the class is on a diagram in Package2 i want the package name and the class name just like EA does.

i've pulled out lots of hair working out both of these problems and i already don't have much to spare.

thanks,
scott

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: two shape script questions
« Reply #1 on: December 03, 2015, 05:50:46 am »
Altering fonts is not possible at all. In order to get different texts displayed as you asked for you need to write an add-in that does the calculation and returns a string that you can print.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: two shape script questions
« Reply #2 on: December 03, 2015, 06:18:50 am »
I'm not  sure you need an addin to show the package name.
Look at the last of the example shapescripts in the manual

Code: [Select]
// SHOW THE NAME OF THE OWNING PACKAGE WHEN THE ELEMENT IS
// USED ON A DIAGRAM NOT IN THAT PACKAGE, AND THE DIAGRAM
// PROPERTIES 'SHOW NAMESPACE' OPTION IS SELECTED.
shape main
{
     layouttype= "border";
     v_align= "CENTER";
     h_align= "CENTER";
     ellipse (0, 0, 100, 100);
     printwrapped ("#name#");
     addsubshape ("path", "S");
     shape path
     {
               v_align= "top";
               h_align= "center";
               if (hasproperty ("packagepath", ""))
               {
               }
          else
               {
                    printwrapped ("(from #packagepath#)");
               }
     }
}

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: two shape script questions
« Reply #3 on: December 03, 2015, 06:50:57 am »
Ah. That's a new one with V12. It's not present in V11 and before.

q.

spelger

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: two shape script questions
« Reply #4 on: December 03, 2015, 06:51:23 am »
qwerty: thanks. too bad about not being able to bold the text, it would have given it a more consistent look.

geert: thanks for the code snippit, that worked like a champ. i tried to go the add-in route that qwerty suggested, in fact i found this which i think is yours: http://bellekens.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/

was not able to get the add-in loaded though. some other time.

thanks again,
scott

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: two shape script questions
« Reply #5 on: December 03, 2015, 08:15:40 am »
You should try again when you got time (and yes, it's Geert's blog). It's a bit tricky to get the shape script calling the add-in, so first get the add-in up, then try the access from shape script.

q.