Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Drawing Methods

Syntax:

<MethodName> "(" <ParameterList> ")";";

Example

shape main

{

 //Initialisation Attributes - these must be before drawing commands

 noshadow = "true";

 h_align = "center";

 

 //drawing commands (Methods)

 rectangle(0,0,100,100);

 println("foo bar");

}

Methods:

Method Name

Description

See also

addsubshape(
 string shapename(
 int width,
 int height ) )

 

Adds a sub-shape with the name shapename that must be defined within the current shape definition.

 

appendcompartmenttext(
 string)

Appends additional strings to a compartment's text.

The compartment the text is added to depends on the compartment name set using setcompartmentname (see below) prior to using appendcompartmenttext.

This method must be called to have the compartment displayed.

 

Add Custom Compartments to Element

arc(
 int left,
 int top,
 int right,
 int bottom,
 int startingpointx,
 int startingpointy,
 int endingpointx,
 int endingpointy)

Draws an elliptical anticlockwise arc with the ellipse having extents at left, top, right and bottom.

The start point of the arc is defined by the intersection of the ellipse and the line from the center of the ellipse to the point (startingpointx, startingpointy).

The end of the arc is similarly defined by the intersection of the ellipse and the line from the center of the ellipse to the point (endingpointx, endingpointy).

 

For example:
 

Arc(0, 0, 100, 100, 95, 0, 5, 0);

arc

 

 

arcto(
 int left,
 int top,
 int right,
 int bottom,
 int startingpointx,
 int startingpointy,
 int endingpointx,
 int endingpointy)

 

As for the arc method, except that a line is drawn from the current position to the starting point of the arc, and then the current position is updated to the end point of the arc.

 

bezierto(
 int controlpoint1x,
 int controlpoint1y,
 int controlpoint2x,
 int controlpoint2y,
 int endpointx,
 int endpointy)

 

Draws a bezier curve and updates the pen position.

 

defSize(int width, int height)

Sets the default size of the element.

This can appear in IF and ELSE clauses with different values in each, and causes the element to be resized automatically each time the values change

 

  if(HasTag("horizontal","true")) {
           defSize(100,20);
           rectangle(0,0,100,100);
  }
  else {
           defSize(20,100);
           rectangle(0,0,100,100);
  }

 
 
The above example sets the shape to the specified default size each time the Tagged Value horizontal is changed.

When this is set, (Alt+Z) also resizes the shape to the defined dimensions.

The minimum value for both int width and int height is 10.

 

 

drawnativeshape()

Causes Enterprise Architect to render the shape using its usual, non-Shapescript notation; subsequent drawing commands are super-imposed over the native notation.

This method is only enabled for element Shape Scripts; line Shape Scripts are not supported.

 

 

ellipse(
 int left,
 int top,
 int right,
 int bottom)

 

Draws an ellipse with extents defined by left, top, right and bottom.

 

endpath()

Ends the sequence of drawing commands that define a path.

 

 

fillandstrokepath()

Fills the previously defined path with the current fill color, then draws its outline with the current pen.

 

 

fillpath()

Fills the previously defined path with the current fill color.

 

 

hidelabel(
 string labelname)

Hides the label specified by labelname, where labelname is one of the following values:

middletoplabel
middlebottomlabel
lefttoplabel
leftbottomlabel
righttoplabel
rightbottomlabel
 

 

image(
 string imageId,
 int left,
 int top,
 int right,
 int bottom)

Draws the image that has the name imageId in the Image Manager.

The image must exist within the model in which the stereotype is used; if it does not already exist in the model, you must import it as reference data or select it from within a technology file.

If the image is in a technology file, it should have a filename of the format <technology ID>::<imagename>.<extension>.

 

Reference Data

Adding Images in MDG Technology

lineto(
 int x,
 int y)

 

Draws a line from the current cursor position to a point specified by x and y, and then updates the pen cursor to that position.

 

moveto(
 int x,
 int y)

 

Moves the pen cursor to the point specified by x and y.

 

polygon(
 int centerx,
 int centery,
 int numberofsides,
 int radius,
 float rotation)

 

Draws a regular polygon with center at the point (centerx, centery), and numberofsides number of sides.

 

print(
 string text)

Prints the specified text string.

You cannot change the font size, type or color of this text.

 

 

printifdefined(
 string propertyname,
 string truepart( ,
 string falsepart ) )

 

Prints the truepart if the given property exists and has a non-empty value, otherwise prints the optional falsepart.

You cannot change the font size, type or color of this text.

 

println(
 string text)

Appends a line of text to the shape and a line break.

You cannot change the font size, type or color of this text.

 

 

printwrapped(
 string text)

Prints the specified text string, wrapped over multiple lines if the text is wider than its containing shape.

You cannot change the font size, type or color of this text.

 

 

rectangle(
 int left,
 int top,
 int right,
 int bottom)

 

Draws a rectangle with extents at left, top, right, bottom. Values are percentages.

 

roundrect(
 int left,
       int top,
       int right,
       int bottom,
       int abs_cornerwidth,
       int abs_cornerheight)

 

Draws a rectangle with rounded corners, with extents defined by left, top, right and bottom.

The size for the corners is defined by abs_cornerwidth and abs_cornerheight; these values do not scale with the shape.

 

setcompartmentname(
 string)

Sets a compartment name to the string provided.

This method must be used before calling appendcompartmenttext (above); calling this after calling appendcompartmenttext clears any text that has already been added to the compartment.

 

Add Custom Compartments to Element

setdefaultcolors()

Returns the brush and pen color to the default settings, or to the user-defined colors if available.

 

Color Queries

setfillcolor(
 int red,
 int green,
 int blue)

setfillcolor(
 Color newColor)

 

Sets the fill color.

You can specify the required color by defining RGB values or using a color value returned by any of the Color Queries such as:

GetUserFillColor()

Color Queries

setfixedregion(
 int xStart,
 int yStart,
 int xEnd,
 int yEnd)

 

Fixes a region in a connector into which a subshape can be drawn, so that the subshape is not rescaled with the length or orientation of the connector line.

For an example, see the end of the table in the Example Scripts topic.

Example Scripts

setlinestyle(
 string linestyle)

Changes the stroke pattern for commands that use the pen.

string linestyle: has the following valid styles:

solid
dash
dot
dashdot
dashdotdot
 

 

setorigin(
 string relativeTo,
 int xOffset,
 int yOffset)

Positions floating text labels relative to the main shape.

relativeTo is one of N, NE, E, SE, S, SW, W, NW, CENTER
xOffset and yOffset are in pixels, not percentage values, and can be negative
 

 

setpen(
 int red,
 int green,
 int blue( ,
 int penwidth ) )

 

Sets the pen to the defined color and optionally sets the pen width.

This method is only for line-drawing commands. It does not affect any text commands.

 

setpencolor(
 int red,
 int green,
 int blue)

setpencolor(
 Color newColor)

Sets the pen color.

You can specify the required color by defining RGB values or using a color value returned by any of the Color Queries

 

GetUserFillColor()

 

This method is only for line-drawing commands. It does not affect any text commands.

 

Color Queries

setpenwidth(
 int penwidth)

Sets the width of the pen. Pen width should be between 1 and 5

This method is only for line-drawing commands. It does not affect any text commands.

 

 

showlabel(
 string labelname)

Reveals the hidden label specified by labelname,  where labelname is one of the following values:

middletoplabel
middlebottomlabel
lefttoplabel
leftbottomlabel
righttoplabel
rightbottomlabel
 

 

startcloudpath(
 puffWidth,
 puffHeight,
 noise)

Similar to StartPath, except that it draws the path with cloud-like curved segments (puffs).

Parameters:

float puffWidth (default = 30), the horizontal distance between puffs
float puffHeight (default = 15), the vertical distance between puffs
float noise (default = 1.0), the randomization of the puffs' positions
 

 

startpath()

Starts the sequence of drawing commands that define a path.

 

 

strokepath()

Draws the outline of the previously defined path with the current pen.