Global Functions

The following global functions are available:

Global functions

Use

CreateModel

(modelkind As Long, filename As String = "", flags As Long =omf_Default) As BaseObject

Creates a new model

CreateModelFromTemplate

(filename As String, flags As Long =omf_Default) As BaseObject

Creates a new model using given model file as template

OpenModel

(filename As String, flags As Long =omf_Default) As BaseObject

Opens an existing model

Output

(message As String = "")

Writes a message in the Script tab of the Output window of PowerDesigner main window

NewPoint

(X As Long = 0, Y As Long = 0) As APoint

Creates a point to position a symbol

NewRect

(Left As Long = 0, Top As Long = 0, Right As Long = 0, Bottom As Long = 0) As Arect

Creates a rectangle to manipulate symbols position

NewPtList () As PtList

Creates a list of points to position a link

NewGUID() As String

Creates a new Global Unique IDentifier (GUID). This new GUID is returned as a string without the usual surrounding "{" "}"

IsKindOf(childkind As Long, parentkind As Long) As Boolean

Returns True if childkind corresponds to a metaclass derived from the metaclass of kind parentkind, False otherwise

ExecuteCommand

(cmd As String, Optional arglist As String, Optional mode As Long) As String

Opens an external application

Rtf2Ascii

(rtf As String) As String

Removes RTF (Rich-Text-File) tags from an RTF formatted text

ConvertToUTF8

(InputFileName As String, OutputFileName As String)

Converts <InputFileName> file into UTF8 (8-bit Unicode Transformation Format, where byte order is specified by an initial Byte-Order Mark) and writes the result to the file <OutputFileName>. The two filenames must be different

ConvertToUTF16

(InputFileName As String, OutputFileName As String)

Converts <InputFileName> file into UTF16 (16-bit Unicode Transformation Format Little Endian, where byte order is specified by an initial Byte-Order Mark) and writes the result to the file <OutputFileName>. The two filenames must be different

EvaluateNamedPath

(FileName As String, QueryIfUnknown As Boolean = True, FailOnError As Boolean = False) As String

Replaces a variable in a path by the corresponding named path

MapToNamedPath

(FileName As String) As String

Replaces the path of a file by the corresponding named path

Progress(Key As String, InStatusBar Boolean = False) As BaseObject

Create or retrieve a given progress indicator

BeginTransaction()

Starts a new transaction

CancelTransaction()

Cancels the ongoing transaction

EndTransaction()

Commits the ongoing transaction

OpenModel(), CreateModel() and CreateModelFromTemplate Flags

OpenModel, CreateModel and CreateModelFromTemplate functions use the following global constants:

Constant

Use

Omf_Default

Default behavior for OpenModel/CreateModel

Omf_DontOpenView

Does not open default diagram view for OpenModel/CreateModel/ CreateModelFromTemplate

Omf_QueryType

For CreateModel ONLY: Forces querying initial diagram type

Omf_NewFileLock

For CreateModel ONLY: Creates and locks corresponding file

Omf_Hidden

Does not let the model appear in the workspace for OpenModel/CreateModel/CreateModelFromTemplate

Command Execution Modes

Command execution modes use the following global constants:

Constant

Use

cmd _ShellExec

Default behavior: lets MS-Windows shell execute the command

cmd _PipeOutput

Redirects the command output to the General tab of PowerDesigner Output window

cmd _PipeResult

Captures the whole command output to the returned string

cmd_InternalScript

Indicates that the first parameter of the Execute Command is a VBScript file to be executed as an internal script rather than letting the system run the application associated with the file type

Example:

'Create a new model and print its name in output window
CreateModel(PDOOm.cls_Model, "C:\Temp\Test.oom|Language=Java|Diagram=SequenceDiagram")
Output ActiveModel.name