Author Topic: Shape Scripts: Text in Subshapes  (Read 2975 times)

M1TO

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Shape Scripts: Text in Subshapes
« on: November 24, 2023, 12:01:48 am »
Hi,

I have a subshape located "outside" the main shape and I want to add text to it. How do I do that? The text always seems to be "attached" to the main shape, no matter what I try.

Code: [Select]
shape main
{
DrawNativeShape();
addsubshape("test", 100, 100);
setfillcolor(0,255,255);

shape test
{
h_align = "center";
v_align = "center";
RoundRect(-15,0,0,15,5,5);
if (HasTag("Test","Yes"))
{
SetFontColor(200,12,0);
print("TestText");
}
}
}
« Last Edit: November 24, 2023, 12:13:15 am by M1TO »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Shape Scripts: Text in Subshapes
« Reply #1 on: November 24, 2023, 12:27:21 am »
Can you explain (with pictures) what you want to achieve, and what is going wrong now?

Geert

M1TO

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Shape Scripts: Text in Subshapes
« Reply #2 on: November 24, 2023, 01:20:10 am »
The text is now shown in the centre of the main shape. But I want it to be in the centre of the subshape, the turquoise rectangle attached to the "north-west" corner of the main shape. Unfortunately I have no idea how to add a picture to this post.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Shape Scripts: Text in Subshapes
« Reply #3 on: November 24, 2023, 02:09:07 am »
The text is now shown in the centre of the main shape. But I want it to be in the centre of the subshape, the turquoise rectangle attached to the "north-west" corner of the main shape. Unfortunately I have no idea how to add a picture to this post.
You can't attach images here. You can post images on a public image hosting site (e.g. imgur.com), and then link them here.

The problem is that you only think you have a subshape outside the main shape.
Actually ou have a subshape the exact same size and location of the main shape addsubshape("test", 100, 100);
Then inside the definition of you subshape you draw a rounded rectangle outside of the borders RoundRect(-15,0,0,15,5,5);
And then you print text in the middle of the subshape (which has the same size and location as the main shape)
Code: [Select]
h_align = "center";
v_align = "center";
print("TestText");

A possible solution:

Code: [Select]
shape main
{
DrawNativeShape();
addsubshape("test", 50, 50, -50, -50);
setfillcolor(0,255,255);

shape test
{
h_align = "center";
v_align = "center";
RoundRect(0,0,100,100,5,5);
if (HasTag("Test","Yes"))
{
SetFontColor(200,12,0);
print("TestText");
}
}
}

Geert

M1TO

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Shape Scripts: Text in Subshapes
« Reply #4 on: November 24, 2023, 07:16:27 pm »
Ahh, I see. Thanks for clarifying that for me!