Page tree

MagicDraw 19.0 LTR SP3 Documentation

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

The code in this section demonstrates some scenarios with a Generic Table tool. The code may not be executable or may not return the correct result. This is only the idea of how to use the Generic Table tool and how it works.

The code shown below prints the row, column, and its value in the form of an HTML table.

#foreach($diagram in $project.getDiagrams("Generic Table"))
	        #set($table = $generic.getTable($diagram))
	        #foreach($colName in $table.columnNames)
	  #foreach($row in $table.rows)
	        #foreach($col in $table.columnIds)
		            <td>$table.getValueAsString($row, $col)</td>

How to learn more about the GenericTableTool

  1. From MagicDraw main menu choose Tools > Report Wizard.
  2. In the Select Template pane, choose Tutorial > Tutorial 27 - Generic Table Export.
  3. Click Next, and choose Built-in for Select Report Data.
  4. Click Next again, Select Element Scope, and then click Next again. Select output options and click Generate.
Generic Table Export dialog
The Generic Table Export dialog.

You can retrieve other diagram table types by using the complete code shown below for getting values from the Generic Table:

#import('generic', '')
#foreach($diagram in $Diagram)
#if($diagram.diagramType == "Generic Table")
#set($table = $generic.getTable($diagram))
#forcol($id in $table.getVisibleColumnIds())$table.getColumn($id)#endcol 
#forrow($row in $table.getRows())
#forcol($id in $table.getVisibleColumnIds())
$table.getValueAsString($row, $id)


You can customize line of code, e.g., by adding diagram table types to get the Metric Table or Instance Table, as shown below:

#if($diagram.diagramType == “Metric Table” || $diagram.diagramType == “Instance Table”)
  • No labels