Hi All,
Since there is a number of questions related to shapescript and the help file in EA is not yet up to date, I thought it would be a good idea if we all post our ShapeScript secrets here for other to benefit from. The following post contains hidden shapescript commands that I determined from contacting Sparks Support.
Hope this helps.
/* SAMPLE TEMPLATE- Creates a Bordered note
with text from the Element Notes field*/
shape Default
{
noshadow = true;
layouttype="border";
moveto(50,0);
lineto(0,0);
lineto(0,100);
lineto(50,100);
//Add Subshapes
addsubshape("padding","W");
addSubShape("line","CENTER");
//Padding Shape definition
shape padding
{
preferredwidth=5;
}
//Text Shape definition
text line
{
PrintWrapped("#NOTES#");
}
}
/* More COMMANDS to access element property fields
The #NOTES# part will retrieve the notes
attribute from the instance that it applies to.
Other Symbols for nodes are:
name
scope
type
classifier
propertytype
stereoType
alias
language
complexity
version
phase
language
packageName
author
status
keywords
isTagged
isAbstract
multiplicity
isroot
isleaf
isSpec
isActive
persistence
notes
cardinality
visibility
concurrency
isEmbedded
isLocked
parentEdge
For paths:
name
direction
type
stereotype
source.multiplicity
target.multiplicity
source.aggregation
target.aggregation
source.multiplicityisorded
target.multiplicityisorded
source.changable
target.changable
source.constraints
target.constraints
source.qualifiers
target.qualifiers
source.targetscope
target.targetscope
source.stereotype
target.stereotype
isroot
isleaf
notes
subtype
*/
/* WITH CONDITIONAL SUBSHAPES - SAMPLE SHAPESCRIPT
(from BPMN notation)*/
shape BPMNActivity
{
layouttype="border";
startpath();
roundrect(0,0,100,100,10,10);
endpath();
fillandstrokepath();
if(HasTag("IsATransaction","true"))
{
roundrect(2,3,98,98,10,10);
}
addsubshape("base","S");
addsubshape("padding","N");
addsubshape("padding","W");
addsubshape("padding","E");
addsubshape("name","CENTER");
text name
{
h_align = "center";
PrintWrapped("#NAME#");
}
shape padding
{
preferredHeight=10;
preferredWidth=10;
}
shape base
{
layouttype="border";
preferredHeight=20;
addsubshape("null","N");
addsubshape("null","S");
addsubshape("baseshapes","CENTER");
shape null
{
preferredHeight=3;
}
shape baseshapes
{
layouttype="leftright";
scalable=false;
v_align="CENTER";
h_align="CENTER";
addsubshape("spacer");
if (HasTag("LoopType","Standard"))
{
addSubShape("loop");
addsubshape("spacer");
}
if (HasTag("LoopType","MultiInstance"))
{
addSubShape("loop");
addsubshape("spacer");
}
if (HasTag("IsMultipleInstance","true"))
{
addSubShape("multiple");
addsubshape("spacer");
}
if (HasTag("IsCompensation","true"))
{
addSubShape("compensation");
addsubshape("spacer");
}
if (HasTag("ActivityType","Sub-Process"))
{
addSubShape("collapsed");
addsubshape("spacer");
}
if (HasTag("AdHoc","true"))
{
addSubShape("adhoc");
addsubshape("spacer");
}
shape spacer
{
preferredWidth=2;
}
shape loop
{
preferredWidth=10;
preferredHeight=10;
setpenwidth(2);
moveto(70,90);
arc(0,0,100,100,70,90,30,90);
//moveto(60,100);
//arc(0,0,100,100,60,100,40,100);
setfillcolor(0,0,0);
startpath();
moveto(-20,100);
lineto(40,100);
lineto(40,60);
endpath();
fillpath();
}
shape multiple
{
preferredWidth=10;
preferredHeight=10;
setfillcolor(0,0,0);
startpath();
rectangle(10,0,40,100);
endpath();
fillandstrokepath();
startpath();
rectangle(60,0,90,100);
endpath();
fillandstrokepath();
}
shape compensation
{
preferredWidth=10;
preferredHeight=10;
setfillcolor(0,0,0);
startpath();
moveto(0,50);
lineto(50,0);
lineto(50,100);
endpath();
fillandstrokepath();
startpath();
moveto(50,50);
lineto(100,0);
lineto(100,100);
endpath();
fillandstrokepath();
}
shape collapsed
{
preferredWidth=10;
preferredHeight=10;
rectangle(0,0,100,100);
moveto(15,50);
lineto(85,50);
moveto(50,15);
lineto(50,85);
}
Shape adhoc
{
preferredWidth=10;
preferredHeight=10;
SetPen(0,0,0,3);
MoveTo(0,50);
StartPath();
PolyBezierTo(50,0,50,100,100,50);
EndPath();
StrokePath();
}
}
}
}
/* SHAPE DECORATIONS - Those little images that
appear on the top right of elements.
This example adds a pale yellow rectangle in
the top-right corner of an element*/
Decoration Test
{
Orientation="NE";
SetFillColor(255,255,200);
StartPath();
Rectangle(0,0,80,100);
EndPath();
FillAndStrokePath();
}
/* EXPLANATION FOR DECORATION COMMANDS:
The orientation command positions the decoration
according to compass position. Valid values
are N, S, E, W, NE, NW, SE, SW and CENTER.
The rectangle command works with percentage
values. Decorations are a fixed size so this
script draws a rectangle the full height but
80% of the width of a full-sized decoration.
The startpath, endpath and fillandstrokepath
commands when used together will fill whatever
is drawn between the start and end with the
defined fill colour (which is defined as a
standard RGB value).
Shape scripts can have conditional logic based
on most of the properties of the chosen element,
and there's a large variety of drawing commands
available.*/