Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Uwe on November 21, 2008, 09:08:46 pm

Title: Shape Script for dependency
Post by: Uwe on November 21, 2008, 09:08:46 pm
Hi,

I'm trying to have a red line as a dependency and it worked all fine with the following script:
---
shape main
{
       // draw a dashed line
       noshadow=true;
       setlinestyle("SOLID");
       setpencolor(255,0,0);
       moveto(0,0);
       lineto(100,0);
}

shape target
{
       // draw an arrow at the target end
       rotatable = true;
       setpencolor(255,0,0);
       startpath();
       moveto(16,-6);
       lineto(0,0);
       lineto(16,6);
       endpath();
       strokepath();
}
---
Unfortinatly I realised, that I had to have different types of connections, some with one arrow, other with two arrows, so here comes my question:
Do you know how to change the script, that it shows an arrow at the end, depending on "direction" drop down in the "dependency properties" dialog ?

Thanks
Title: Re: Shape Script for dependency
Post by: Eve on November 24, 2008, 08:41:57 am
Shape scripts support conditional branching (http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/conditional_branching.html) and you can get the connector direction (http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/displaying_element_properties.html).  That should be all you need.
Title: Re: Shape Script for dependency
Post by: Thomas H. on November 25, 2008, 03:08:37 am
Maybe the following helps (please adjust the color RGB values):

shape main
{
  // draw a dashed line
  noshadow=true;
  setpencolor(100,100,100);
  setlinestyle("DASH");
  moveto(0,0);
  lineto(100,0);
}
 
shape source
{
  rotatable = true;

  if(HasProperty("Direction","Bi-Directional")) {
    startpath();
    setfillcolor(100,100,100);
    setpencolor(100,100,100);
    moveto(0,0);
    lineto(16,6);
    lineto(16,-6);
    endpath();
    fillandstrokepath();
  }

  if(HasProperty("Direction","Destination -> Source")) {
    startpath();
    setfillcolor(100,100,100);
    setpencolor(100,100,100);
    moveto(0,0);
    lineto(16,6);
    lineto(16,-6);
    endpath();
    fillandstrokepath();
  }
}

shape target
{
  rotatable = true;

  if(HasProperty("Direction","Bi-Directional")) {
    startpath();
    setfillcolor(100,100,100);
    setpencolor(100,100,100);
    moveto(0,0);
    lineto(16,6);
    lineto(16,-6);
    endpath();
    fillandstrokepath();
  }

  if(HasProperty("Direction","Source -> Destination")) {
    startpath();
    setfillcolor(100,100,100);
    setpencolor(100,100,100);
    moveto(0,0);
    lineto(16,6);
    lineto(16,-6);
    endpath();
    fillandstrokepath();
  }
}
Title: Re: Shape Script for dependency
Post by: Uwe on January 10, 2009, 01:29:00 am
Thanx this helped a lot.