Author Topic: Shape Script - Subshape in target shape  (Read 403 times)

Plonka

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Shape Script - Subshape in target shape
« on: May 01, 2025, 12:11:16 am »
Hello,
I have a problem using shape script.
I extend the dependency connector in my MDG. Everything works fine but i can not make a subshape run in the target shape.
Target is a fixed name for the shape that creates the arrowhead of a connector. At least thats what I understand.
When entering the code below in the Shape Editor, the shape is displayed as i expected.

But when using my MDG the desired black circle is not visible.
When I copy the code from addsubshape("Circle",....) including the whole shape circle {...} the circle is shown.

What am i missing?  Could it be the sizing of the subshape? Tried to handle that by making the sub shape (100,100) big.
(How the Coordinates, widths and heights work is still a miracle to me)

Kind regards
Plonka



Code: [Select]
shape main
{
// Defines the normal line of the arrow
layouttype="topdown"; // <- needed here ?
noshadow=true;
//setpen(getDefaultLineColor()); // <- Don`t know of this works.
setlinestyle("solid");
moveto(0,0);
lineto(100,0);

//  ***When i put the subshape here, the Circle appears (random) on the connector line***
// addsubshape("circle",100,100,0,0);

// shape circle // defines a small Circle on the tip of the arrowhead -> does not work
// {
// scalable = false;
// rotatable = true;
// setpen(0,0,0,1);
// setfillcolor(0,0,0);
// startpath();
// ellipse(0,-5,10,5);
// endpath();
// fillandstrokepath();
// }
//
}

shape target // Defines the Arrowhead
{
layouttype="topdown"; // <- needed here ?
rotatable = true;
startpath();
moveto(0,0);
lineto(16,6);
moveto(0,0);
lineto(16,-6);
endpath();
strokepath();

// ***If I draw the circle here, it works fine***
// setpen(0,0,0,1);
// setfillcolor(0,0,0);
// startpath();
// ellipse(0,-5,10,5);
// endpath();
// fillandstrokepath();


addsubshape("circle",100,100,0,0);

shape circle // defines a small Circle on the tip of the arrowhead -> does not work
{
scalable = false;
rotatable = true;
setpen(0,0,0,1);
setfillcolor(0,0,0);
startpath();
ellipse(0,-5,10,5);
endpath();
fillandstrokepath();
}
}