Book a Demo

Author Topic: Maintain text placement in shapescript  (Read 2961 times)

GrahamL

  • EA User
  • **
  • Posts: 111
  • Karma: +2/-0
    • View Profile
Maintain text placement in shapescript
« on: June 19, 2020, 06:28:36 pm »
Hi
AN element is defined by a shape script to be a parellogram and includes an identifier placed in the top left corner.
When used on a diagram this element is displayed correctly but when resized the text in the top left is not adjusted and is now outside the shape.
Is there a way of fixing this?
THnaks

shape main
{
   noShadow=true;
   fixedAspectRatio = "true";
   DefSize(100,100);
   setfillcolor(255,255,255); // default is white

   if (HasTag('GSN Status','Completed'))
   {
      setfillcolor(0,176,80);
   }
   if (HasTag('GSN Status','Work In Progress'))
   {
      setfillcolor(255,192,0);
   }
   if (HasTag('GSN Status','Behind Schedule'))
   {
      setfillcolor(255,0,0);
   }
   if (HasTag('GSN Status','Not Required Now'))
   {
      setfillcolor(0,176,240);
   }
      startpath();
   moveto(10,0);
   lineto(100,0);
   lineto(90,70);
   lineto(0,70);
   lineto(10,0);
   endpath();
   fillandstrokepath();
 
   SetOrigin("NW",15,5);
   addsubshape("Name", 200,20);
   AddSubShape("title");

    shape Name
   {
      bold=true;
      print("#NAME#");
   }
 
   shape title
   {
      bold=false;
      if (HasTag('Title'))
      {
         print ("#TAG:Title#");
         //print ("asdasda");
      }
   }
}



Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Maintain text placement in shapescript
« Reply #1 on: June 22, 2020, 05:04:54 pm »
Hi Graham,


Just a shot in the dark, but perhaps SetOrigin() confuses EA. There is another version of AddSubShape() that takes two additional parameters which specify the placement of the sub-shape in the parent shape. It's not listed among the drawing methods and it doesn't appear as an option in the shape script editor, but it is used in the sub-shape examples so I guess we can't strictly speaking say it's undocumented.

So playing around with that might be worth a shot.

Also, I tested your shape script on a Class in 15.0 and the text stayed put. So if you're on an older version the behaviour might be due to a bug that's subsequently been fixed.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

GrahamL

  • EA User
  • **
  • Posts: 111
  • Karma: +2/-0
    • View Profile
Re: Maintain text placement in shapescript
« Reply #2 on: June 22, 2020, 05:20:20 pm »
Hi
Yes that seemed to fix it, thanks

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Maintain text placement in shapescript
« Reply #3 on: June 29, 2020, 10:48:33 am »
The problem is that the shape you are drawing is defined using percentages of the total element size.

I have shared a script at some point that create a node style element where the element dimensions don't change the depth using setfixedregion(). You could adapt that to work with your parellogram.