0% found this document useful (0 votes)
12 views30 pages

ProModel ActiveX Capabilities Guide

Programacion en Promodel

Uploaded by

Guido Salazar S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views30 pages

ProModel ActiveX Capabilities Guide

Programacion en Promodel

Uploaded by

Guido Salazar S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

556 East

Technology Ave
OREM
UTAH 84097
801.223.4600
The information in this addendum has been provided by PROMODEL Corporation to document the ActiveX capabil-
ities of ProModel, MedModel, and ServiceModel. The information in this addendum is subject to change without
notice and does not represent a commitment on the part of PROMODEL Corporation. The software described in this
addendum is supplied under a license agreement and may be copied only under the terms of the license agreement.
No part of this addendum may be reproduced or transmitted in any form, or by any means, electronic or mechanical,
including photocopying, for any purpose other than the owner’s personal use, without the express written permission
of PROMODEL Corporation.
© 12/5/05 PROMODEL Corporation.
All rights reserved.
Printed in the United States of America

ProModel, MedModel, and ServiceModel are registered trademarks of PROMODEL Corporation.


Unless otherwise noted, all reference to company names, products, and persons contained in this guide are com-
pletely fictitious and are used solely to document the use of ProModel, MedModel, and Servicemodel.

Visual Basic and ActiveX are trademarks of Microsoft Corporation.

12/5/05
ProModel iii
ActiveX

Table of Contents

Table of Contents .................................................................................iii

Introduction ......................................................................................... 1

Chapter 1:
The ProModel Application Object ...........................................................................8

EndReplication ............................................................................................9
EndSimulation ...........................................................................................10
GetEventsObject ........................................................................................11
GetSimTime ...............................................................................................12
GetStatus ....................................................................................................13
GetVersion .................................................................................................14
LoadDefaults .............................................................................................15
LoadModel .................................................................................................16
MenuCommand .........................................................................................17
MergeModel ..............................................................................................18
MsgBox .....................................................................................................19
New ............................................................................................................20
OpenModule ..............................................................................................21
Quit ............................................................................................................22
RedrawLayout ...........................................................................................23
RedrawTables ............................................................................................24
RunScenarios .............................................................................................25
Save ...........................................................................................................26
SaveAs .......................................................................................................27
SetMacro ....................................................................................................28
SetMenus ...................................................................................................29
SetMessageMode .......................................................................................30
SetPan ........................................................................................................31
SetView .....................................................................................................32
SetViewRect ..............................................................................................33
SetWindowPos ...........................................................................................34
iv

ShowTranslationDlg ..................................................................................35
Simulate .....................................................................................................36
Zoom ..........................................................................................................37

Chapter 2:
The ProModel Events Object .................................................................................38

PMEventsHandler ......................................................................................39
AnimSpeedChange ....................................................................................41
InputTextPrompt ........................................................................................42
ListSelectPrompt .......................................................................................44
RunError ....................................................................................................46
TranslationError .........................................................................................47
UserZoom ..................................................................................................48

Chapter 3:
The ProModel Runtime Object ..............................................................................49

GetAnimationState ....................................................................................50
GetAnimationSpeed ...................................................................................51
GetStatValue ..............................................................................................52
SetAnimationState .....................................................................................54
SetAnimationSpeed ...................................................................................55
SetStatValue ..............................................................................................56

Chapter 4:
The ProModel Data Object ...................................................................................57

AddBackgroundBitmap .............................................................................58
AppendEntitySpot .....................................................................................59
AppendGraphicIcon ...................................................................................60
AppendGraphicIconSize ............................................................................61
AppendRecord ...........................................................................................62
AppendRoutingPoint .................................................................................63
DeleteRecord .............................................................................................64
GetIntFieldValue .......................................................................................65
GetRealFieldValue ....................................................................................66
GetRecordCount ........................................................................................67
GetSelectedsFromType .............................................................................68
GetStringFieldValue ..................................................................................69
InsertRecord ...............................................................................................70
ProModel v
ActiveX

Populate .....................................................................................................71
SelectMainRecordByIndex ........................................................................72
SelectMainRecordByName .......................................................................73
SetIntFieldValue ........................................................................................74
SetRealFieldValue .....................................................................................75
SetStringFieldValue ...................................................................................76

Chapter 5:
The RDBDataServer Object ...................................................................................77

CloseFile ....................................................................................................78
FieldName .................................................................................................79
GetPositionInfo ..........................................................................................80
GetValue ....................................................................................................81
OpenFile ....................................................................................................82
PeriodName ...............................................................................................83
PositionIsValid ..........................................................................................84
RecordName ..............................................................................................85
ReplicationNumber ....................................................................................86
ScenarioName ............................................................................................87
SelectData ..................................................................................................88
TableName .................................................................................................89

Appendix:
Table Definitions .................................................................................................... 91

ProModelData Table Definitions ...............................................................91


Runtime Table. ........................................................................................114
Result Codes (Errors) ..............................................................................118
Events ......................................................................................................119
Path Colors ..............................................................................................120
Menu Ids ..................................................................................................121

Index ................................................................................................ 125


vi
ProModel 1
ActiveX

Introduction

ProModel’s ActiveX Components

ProModel’s ActiveX Automation capability allows you to use any ActiveX-enabled language (e.g. Microsoft Visual
Basic, VBA, or Visual C++) to:

•Build customized user interfaces for ProModel


•Add, Change or Delete model data from external data sources, such as spreadsheets, databases or ASCII text
files
•Control ProModel from another application
•Extract output data and place it in a spreadsheet or database

The intent of this manual is to give you information that is specific to the ActiveX components automatically installed
with your PROMODEL product. We have included plenty of examples to help you understand how to use these
powerful tools. All of the examples that follow use Visual Basic commands and syntax. The variable names used in
this manual are merely examples, you will want to replace them with names that are meaningful to you.

ProModel Objects

All of the Type Libraries have an Application object, a Data object and a Runtime object. Each object gives you
access to different parts of ProModel. The following is a brief description of these objects:

•Application – gives you operational control of ProModel. For example, using this object you can load a model
or start a simulation.
•Data – allows you to access to model information (like Locations or Processing records).
•Runtime – gives you methods that can update or capture the values of statistics while a simulation is running.

When you declare object variables, we recommend that you use the ProModel object types. Here are examples of
how to declare and create an instance of each of the ProModel objects.

ProModel Type Library

Dim ObjVarName as ProModel.CProModel


Set ObjVarName = CreateObject(“ProModel”)

Dim ObjVarName as ProModel.CProModelData


Set ObjVarName = CreateObject(“ProModelData”)

Dim ObjVarName as ProModel.CRuntime


Set ObjVarName = CreateObject(“ProModel.CRuntime”)

ProModelPM Type Library (ProModel product)


2

Dim ObjVarName as PromodelPM.Application


Set ObjVarName = CreateObject(“PromodelPM.Application”)

Dim ObjVarName as PromodelPM.Data


Set ObjVarName = CreateObject(“PromodelPM.Data”)

Dim ObjVarName as PromodelPM.Runtime


Set ObjVarName = CreateObject(“PromodelPM.Runtime”)

PromodelMM Type Library (MedModel product)

Dim ObjVarName as PromodelMM.Application


Set ObjVarName = CreateObject(“PromodelMM.Application”)

Dim ObjVarName as PromodelMM.Data


Set ObjVarName = CreateObject(“PromodelMM.Data”)

Dim ObjVarName as PromodelMM.Runtime


Set ObjVarName = CreateObject(“PromodelMM.Runtime”)

PromodelSM Type Library (ServiceModel product)

Dim ObjVarName as PromodelSM.Application


Set ObjVarName = CreateObject(“PromodelSM.Application”)

Dim ObjVarName as PromodelSM.Data


Set ObjVarName = CreateObject(“PromodelSM.Data”)

Dim ObjVarName as PromodelSM.Runtime


Set ObjVarName = CreateObject(“PromodelSM.Runtime”)

Other Objects

ProModel also provides a few other objects that will enable you to:

•Access the data found in the classic output statistics files (*.rdb, *.rdt).
•Capture and respond to events that take place in ProModel

There are three files that allow you to work with the classic output statistics. They are:

•Rdbsrv.exe – gives you access to the data contained in the General Statistics report. This has been included with
previous versions of ProModel.
•Rdbsvr.dll – This DLL gives you access to the General Statistics, but does it much faster than rdbsrv.exe.
•Rdtdata.dll – This DLL gives you access to the Time Series data.

The “ProModel Events 2.0 Type Library” (pmcp53.dll) gives you a way to control things that happen (events) in Pro-
Model. With it, you can:

•Trap and respond to errors without user intervention


ProModel 3
ActiveX

•Hide informational messages


•Get information about changes the user makes during simulation, such as changing the animation speed or the
view.
•Handle ProModel “Prompt” dialogs or replace them with your own dialogs

Methods

Each ProModel ActiveX Object has one or more methods (actions it can perform).

Each method may or may not have Parameters (details that you provide or that ProModel returns).

Syntax

Most methods can be used in two different ways. The first example shown below does not have a variable to receive
the result code. The second example uses a slightly different syntax that will enable you to determine whether or not
the method executed successfully.

Syntax 1

If you don’t need to know whether the method succeeded or failed, use the method name, followed by a space, then
each parameter. Use a comma to separate the parameters.

Sub FindRecord()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData

Set pmObject = CreateObject(“ProModel”)


Set pmDataObject = CreateObject(“ProModelData”)
pmDataObject.Populate

pmDataObject.SelectMainRecordByName 1, “MyLocation”

Set pmObject = Nothing


Set pmDataObject = Nothing
End Sub

Syntax 2:

When you use this syntax, you can determine what happened when the method was executed. You will need to
declare a variable to hold the result code returned by ProModel. In the method call, start with that variable, then an
equals (=) sign, followed by the method name and a left parenthesis. As with Syntax 1, the parameters are listed in
order, separated by commas. Finally, a right parenthesis closes the method call.

Sub FindRecord()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim vResultCode as Long

Set pmObject = CreateObject(“ProModel”)


Set pmDataObject = CreateObject(“ProModelData”)
pmDataObject.Populate

vResultCode = pmDataObject.SelectMainRecordByName (1, “MyLocation”)

If vResultCode <> 0 Then


4

MsgBox “Record Not Found”


End If

Set pmObject = Nothing


Set pmDataObject = Nothing
End Sub

Result Codes

Almost all of the methods in the ProModelData object may optionally be written to return a result code. Result codes
help you know if the execution of the method was succesdsful. For a list of result codes, see “Result Codes (Errors)”
on page 118.

Definitions

Record Type = Table Number

Record = Row

Record Index = Row Number

Field = Column

Field Index = Column Number

Parameters

ProModel has two kinds of parameters: Input Parameters and Output Parameters. Each parameter has a specific data
type. In this document, the data types shown are Visual Basic data types. If you are programming in another
ActiveX enabled language, you will need to use the equivalent types in that language.

For input parameters, you may place a value of the correct type directly in the method call, or place the value into a
variable of the appropriate type, then use the variable to satisfy the parameter requirements. For output parameters
you must supply a variable of the appropriate type to receive the values returned by ProModel.

For output parameters, you must use a variable.

Although some programming languages will automatically convert one data type to another, you may need to use
variables to work with some numbers. In the example for the Zoom method, shown on page 37, you will notice that
a variable of type Double is declared, then the numeric value is placed in that variable, and the variable is used in the
method call. If the Zoom method is executed with a number as the parameter, an error is raised, because Visual Basic
automatically converts the number, but not to the correct type. So, by placing the number in a variable explicitly
defined as a Double, the problem of incorrect conversion is avoided. Other languages may have similar limitations.

PM Constants

You may have noticed that the first parameter in the “SelectMainRecordByName” method used in the code sample in
the Syntax section contains a number. This number references the Locations table. Because it can be difficult to
remember the number codes associated with so many tables, fields, status codes, etc. we have developed text values
that you may use in place of the numbers. To use the pre-defined constants, simply include the PMConstants.bas in
one of your program modules. Whether you use the pre-defined constants, your own constants or the numbers in
your code makes no difference to ProModel. You can even use constants and numbers in the same method call. See
the PM Constants chapter for a complete list of pre-defined constants, their values and descriptions.
ProModel 5
ActiveX

Working with Data

When you create a model, what you are actually doing is recording information about your business processes. When
you run a simulation, ProModel takes that information and uses it to display an animated representation of your pro-
cesses and to generate the statistical information about your processes.

You can think of each model you create as a database. Within each model database there are many tables, such as
Locations, Path Networks, and Processing. ProModel’s ActiveX uses numbers to reference each table. In the appen-
dix, you will find a list of tables and their corresponding numbers.

Each table contains one or more fields. You may have records in many of these tables, with information in some of
the fields. If you are accustomed to spreadsheets, each model would be a workbook, each table a sheet. Fields would
correspond to columns and records would be the rows. Fields and records are also referenced by number. A complete
list of tables and fields, along with their reference numbers, can be found in Appendix A on page 91.

With a database, you have an element that is not as easy to create in a spreadsheet, the parent-child relationship.
Since ProModel is a database environment, there are many tables that have that type of relationship. Let’s look at
something a little more concrete.

Suppose you have just started a new model and have defined the locations shown below:

For each of these three locations, there is more that one graphic icon. In addition, the conveyor for Loc2 has a couple
of joints (bends) in it. So, your Locations table would have three records. Each of these records would have more
than one graphic. Information about the graphics is stored in a different table, which is a child of the Locations table.
The child table (Location Graphics) also has a child of its own, the Q/Conveyor Joints table. A diagram of the table
relationships would look something like this:

Locations Location Graphics Q/Conveyor Joints


1. Loc1 1. Part Spot
2. Text Box
3. Counter
2. Loc2 1. Conveyor 1. Start Point
2. First Bend
3. Second Bend
4. End Point
2. Text Box
3. Loc3 1. Part Spot
2. Text Box
If we want to change the name of Loc1 to “EntryPoint”, we would need to make that change in the first record of the
Locations table (table number 1). So, we would select record one in table one.
6

If we want to move Loc3 to a different place in the layout, we would first need to select the Loc3 record in the parent
table (Locations). Then we can select records in the child table (Location Graphics – table 45) and change the X and
Y values of each.

Now, if we want to move the end of the Loc2 conveyor closer to our new Loc3 position, we first need to select Loc2
in the parent table (Locations). Then, we would select Conveyor in the child table (Location Graphics) for Loc2.
Finally, we can select the End Point record in the second level child table (Q/Conveyor Joints – table 61) and change
its X and Y values.

You may have realized from the description above that you must always select a record before you can work with any
of the information in that record. This holds true for all of the data tables in ProModel. Records can be selected
either by name (if it has one) or by index number. The index number is the number in the upper right corner of the
data window in ProModel and represents the record’s position in the table (its row number). When a new record is
added to a table in ProModel, that record is automatically selected. If a record is deleted from a table, the index num-
bers of following records will be changed to close the gap.

The fields (columns) are also numbered, from left to right. One caveat: the first field is not always the one you might
think it is. For example, the Name field in the Locations table is actually number two. Field one is no longer used.

Working with Graphics

Though the basic principles for working with data in the graphics tables are the same as working with any other data
table in ProModel, there are some things that work a bit differently. This section covers those differences.

We have already indicated that the Location Graphics table is a child of the Locations table. Entities and Resources
also have their own graphics tables. The graphics information for the Path Networks table are actually included in the
parent table (it has other children).

With most data tables in ProModel, there are two methods available for adding new records – the AppendRecord and
InsertRecord methods. When working with any of the Graphics child tables, only the AppendRecord() is used, Inser-
tRecord() will return an error.

Because there are many types of graphics associated with locations, working with the Location Graphics table can be
a bit tricky at first. Let’s look at the example we used previously:

Suppose that we want to add a Counter graphic to Loc3.

First, we must select the record for Loc3 in the Locations table. Then, we would use the AppendRecord method with
the Location Graphics table. A library graphic is automatically created. However, we don’t want a Library graphic,
so we must use the SetIntFieldValue method to change the value in the Type field to 4 (Counter).

With other data tables, the SetIntFieldValue method would simply replace the value in the specified field. Not so in
the Location Graphics table. When using this method on the Type field, it actually deletes the library graphic record,
then appends a new record (counter graphic) and sets the value of the Type field to 4. This is fine if you have just
appended a new record, but what if you want to change the Type of an existing graphic?
ProModel 7
ActiveX

Unless the graphic you wish to change is the last record in the table, the index number will change (because the
record is deleted and then a new record added to the end of the table). This also means that the index number of other
graphics may change, as outlined earlier.

Changing the graphic type also modifies the apparent structure of the Location Graphics table itself. Each graphic
type has different fields associated with it. (see “Location Graphics (45): pmdTblLocGraphic” on page 107). A field
by the same name may have different numeric values for different graphic types. The one constant is the Type field,
it is always field 1.

What if we create a location, then we append a graphic and we want to change it to a Queue? When we change the
value in the Type field to 2, the same process as above takes place, but a few more things happen as well. The
Graphic Style field will have the default value of 2 (Line style), and two records will be added to the next level child
table (Q Joints table, #61). The first record in the Q Joints table will have the X Position and Y Position both set to
zero (0), indicating that the queue starts at the top left corner of the layout. The second record will have default X and
Y values of 100, indicating that the queue ends 100 pixels to the right and 100 pixels down from there.

After that, you may work with the other fields of the Location Graphics table to further define how the Queue or Con-
veyor will look and function. You may also change the X and Y position values of the two records in the Queue/Con-
veyor Joints table, or add more joints by appending records. However, you cannot delete the two default records,
since you cannot have a queue or conveyor with only one end. To delete the queue or conveyor, you must delete the
record in the Location Graphics table.

You may notice as you work with Library Graphics that there is no easy way to determine what the Graphic ID num-
ber is for any given graphic icon. However, the Graphic ID is a required field when the graphic type is 1. The
Graphic Editor is an application that is included with ProModel for your convenience. Unfortunately, as you add,
change and delete icons in your graphics libraries, you may end up with numbers out of sequential order or missing
altogether.

The following chapters will give you detailed information and examples for each of the objects and methods available
with your installation of ProModel.
8 Chapter 1:

Chapter 1:
The ProModel Application Object

The ProModel Application object is found in pm.exe, mm.exe, and sm.exe as “ProModel”, “ProModel Type
Library”, “ProModelPM”,or “ProModel PM Type Library”. If one or more of these libraries are not available in
your References list, run PM.EXE (found in your ProModel folder) with the “ /regserver” command line option.

The ProModel Application object may be used with Runtime versions of ProModel. The ProModel Application
object has methods that control all the commonly used functions of ProModel, as well as the method used to initialize
the Events object. The available methods are listed below, grouped by area of functionality.

•EndReplication
•EndSimulation
•GetEventsObject
•GetSimTime
•GetStatus
•GetVersion
•LoadDefaults
•LoadModel
•MenuCommand
•MergeModel
•MsgBox
•New
•OpenModule
•Quit
•RedrawLayout
•RedrawTables
•RunScenarios
•Save
•SaveAs
•SetMacro
•SetMenus
•SetMessageModes
•SetPan
•SetView
•SetViewRect
•SetWindowPos
•ShowTranslationDlg
•Simulate
•Zoom
ProModel 9
ActiveX

EndReplication
Syntax: EndReplication
Description: Terminates a Replication before completion. Simulation will then proceed to the next repli-
cation. If EndReplication is called during the final replication, the simulation will end.
Parameters: None
Returns: Nothing
Example: This example loads a model, runs simulation for 30 minutes (1800 seconds), then terminates
the current replication.
Sub QuitSimEarly()
Dim pmObject As ProModel.CProModel
Dim CurSimTime AS Double

CurSimTime = 0
Set pmObject = CreateObject(“ProModel”)
pmObject.LoadModel ("C:\ProModel 2001\Models\Demos\mfg_cost.mod")
pmObject.Simulate

Do While CurSimTime < 1800


pmObject.GetSimTime CurSimTime
DoEvents
Loop

pmObject.EndReplication

Set pmObject = Nothing


End Sub
10 Chapter 1:
EndSimulation

EndSimulation
Syntax: EndSimulation
Description: Terminates a simulation run before completion. The EndSimulation method will have no
effect if called when there is no simulation running. If running multiple replications, the entire simulation
will end (remaining replications will not be run).
Parameters: None
Returns: Nothing
This example loads a model, runs it for 30 minutes (1800 seconds), then terminates the simulation.
Sub QuitSimEarly()
Dim pmObject As ProModel.CProModel
Dim CurSimTime AS Double

CurSimTime = 0
Set pmObject = CreateObject(“ProModel”)
pmObject.LoadModel ("C:\ProModel 2001\Models\Demos\mfg_cost.mod")
pmObject.Simulate

Do While CurSimTime < 1800


pmObject.GetSimTime CurSimTime
DoEvents
Loop

pmObject.EndSimulation

Set pmObject = Nothing


End Sub
ProModel 11
ActiveX

GetEventsObject
Syntax: GetEventsObject
Description: Use this method to initialize the ProModel Events object. For further instructions see the
Events Handler section.
Parameters: None
Returns: Event Handler object.
Example: This example is incomplete, but the code given shows how to use the GetEventsObject
method. This must be executed before using the Events Handler.
Sub GenericSub()
Dim pmObject As ProModel.CProModel
Dim pmEventObject As PMCPLib.PMEvents

Set pmObject = CreateObject("ProModel")


Set pmEventObject = pmObject.GetEventsObject
**More Code…
End Sub
12 Chapter 1:
GetSimTime

GetSimTime
Syntax: GetSimTime (Seconds)
Description: Gets the current simulation time in seconds.
Parameters:
Seconds (Double) Output parameter that receives return value.
Returns: (Double) Current simulation clock time in seconds.
Example: This example loads a model, runs it for 30 minutes (1800 seconds), then terminates the simula-
tion.
Sub QuitSimEarly()
Dim pmObject As ProModel.CProModel
Dim CurSimTime AS Double

CurSimTime = 0
Set pmObject = CreateObject(“ProModel”)
pmObject.LoadModel ("C:\ProModel 2001\Models\Demos\mfg_cost.mod")
pmObject.Simulate

Do While CurSimTime < 1800


pmObject.GetSimTime CurSimTime
DoEvents
Loop

pmObject.EndSimulation
Set pmObject = Nothing
End Sub
ProModel 13
ActiveX

GetStatus
Syntax: GetStatus
Description: Gets the current state of a loaded model. Use this method to trap events triggered by Pro-
Model or the user. Note: This method is easier to use than the Events Handler, but less robust and reliable
For instance, the GetStatus method will work fine for simple applications, but for more complicated situa-
tions, such as running a series of models, it would work better to use the event handler approach to avoid
problems with timing issues.
Parameters: None
Returns: Long. Status code (0 – 9) of the loaded model.
Status Codes:
0. Status unknown
1. No model loaded
2. Loading a model
3. Model loaded
4. Load error
5. Translating model
6. Simulation in progress
7. Simulation or translation terminated pre-maturely
8. Simulation completed
9. Simulation frozen
Example: This example starts the simulation for the loaded model and continuously checks the status.
Then, when the status changes to 8 (normal completion), shows a message to let the user know it’s done.
Sub WhatsUp()z
Dim pmObject As ProModel.CProModel
Dim vStatus As Long

Set pmObject = CreateObject("ProModel")


pmObject.Simulate
vStatus = pmObject.GetStatus

Do
DoEvents
vStatus = pmObject.GetStatus
Loop Until vStatus = 8

MsgBox "I'm done."


Set pmObject = Nothing
End Sub
14 Chapter 1:
GetVersion

GetVersion
Syntax: GetVersion
Description: Returns the version of the product you are using. This could be used to make certain that
the user’s version of ProModel is recent enough to contain certain features.
Parameters: None.
Returns: (String) Version number and build number shown in the ‘Help > About’ dialog box in ProModel.
Example: This example opens ProModel then returns the version information to the variable.
Sub VerNum()
Dim pmObject As ProModel.CProModel
Dim pmVersion As String

Set pmObject = CreateObject("ProModel")


pmVersion = pmObject.GetVersion
MsgBox "You are using version " & pmVersion
Set pmObject = Nothing
End Sub
ProModel 15
ActiveX

LoadDefaults
Syntax: LoadDefaults ININame
Description: Reloads the INI file, which contains the ProModel defaults. The INI name is ingnored.
Parameters:
ININame The name of the INI file with the desired defaults.
16 Chapter 1:
LoadModel

LoadModel
Syntax: LoadModel FileName
Description: Loads the specified model.
Parameters:
FileName (String) Any valid path and model filename. Model files must have a .mod extension.
Returns: Nothing
Example: This example loads a model, runs it for 30 minutes (1800 seconds), then terminates the simula-
tion.
Sub QuitSimEarly()
Dim pmObject As ProModel.CProModel
Dim CurSimTime AS Double

CurSimTime = 0
Set pmObject = CreateObject(“ProModel”)
pmObject.LoadModel ("C:\Program Files\ProModel\Models\Demos\mfg_cost.mod")
pmObject.Simulate

Do While CurSimTime < 1800


pmObject.GetSimTime CurSimTime
DoEvents
Loop

pmObject.EndSimulation

Set pmObject = Nothing


End Sub
ProModel 17
ActiveX

MenuCommand
Syntax: MenuCommand CmdNum, lParam
Description: Executes a specified menu option (as if the user had selected it).
Parameters:
CmdNum (Long) The ID number of the menu command you wish to use. See “Menu Ids” on
page 121.
lParam (Long) For almost all MenuIDs, Parameter has no meaning, so a zero should be
passed. For #4825 (Interactive Subroutine), Parameter will activate a specific subrou-
tine. The number in Parameter refers to the order of the subroutine in the “Interact”
list available during simulation, not it’s index number in the Subroutine table.
Returns: Nothing
Example: The following example loads a model, then opens the General Information dialog.
Sub ChangeView()
Dim pmObject As ProModel.CProModel

Set pmObject = CreateObject(“ProModel”)


pmObject.LoadModel ("C:\Program Files\ProModel\Models\Demos\mfg_cost.mod")
pmObject.MenuCommand 2863, 0

Set pmObject = Nothing


End Sub
18 Chapter 1:
MergeModel

MergeModel
Syntax: MergeModel FileName, Xpos, Ypos, Tag, Flags
Description: Merges the specified model into the currently loaded model. Model merging is useful when
you wish to join sub models or fragmented model components to the original model.
Parameters:
FileName (String) The name of the file you wish to merge.
Xpos (Double) Horizontal placement of submodel (number of pixels over from left margin).
Ypos (Double) Vertical placement of submodel (number of pixels down from the top mar-
gin)
Tag (String) A label attached to the beginning or end of every identifier in the merged
model.
Flags (Long) You can use flags to specify merge options such as whether to attach a tag to
the beginning or end of identifiers, or whether or not to merge graphics libraries. Flags
should be combined using the “Or” operator.
Returns: (Long) Result of the merge operation (whether it was successful or not).
Flags: When using more than one flag, use the keyword “Or” to connect, or simply add the values of the
flags together, and enter that value for all flags.
2 Don’t prompt
8 Prefix tag (default is suffix)
16 Merge new model’s graphic library into the current model and save with original name
32 Merge new model’s graphic library into the current model and save as the original name plus the
model tag
64 Just use the original model’s graphic library
Example: This example loads a model, then merges in 24hrclok.mod at an offset of 20x20 pixels from the
upper-left corner of the layout. All identifiers associated with the 24 hr. clock will have “sub_” added to the
beginning.
Sub AddClock()
Dim pmObject As ProModel.CProModel
Dim MySubMod As String

Set pmObject = CreateObject("ProModel")


pmObject.LoadModel "C:\Program Files\ProModel\Models\Demos\mfg_cost.mod"
MySubMod = "C:\Program Files\ProModel\Models\Demos\mfg_cost.mod"
pmObject.MergeModel MySubMod, 175, 125, "sub_", 8 Or 64

Set pmObject = Nothing


End Sub
ProModel 19
ActiveX

MsgBox
Syntax: MsgBox Message
Description: Displays a message box containing the indicated text. The message box will display in Pro-
Model. If you wait for a response from within Excel or a custom VB interface, you may not see the mes-
sage box. This may delay operations while the dialog awaits a response.
Parameters:
Message (String) The message you wish to display.
Returns: Nothing
Example: This example loads a model, then sends a message to the ProModel window that the user must
clear before the next line of code will be executed.
Sub Hal()
Dim pmObject As ProModel.CProModel

Set pmObject = CreateObject("ProModel")


pmObject.LoadModel "c:\promodel 2001\models\demos\mfg_cost.mod"
pmObject.MsgBox "Good Morning, Dave."

Set pmObject = Nothing


End Sub
20 Chapter 1:
New

New
Syntax: New
Description: Invokes the File/New command without launching the General Information Dialog.
Parameters: None
Returns: Nothing
Example: This example opens ProModel and loads a new (empty) model.
Sub NewMod()
Dim pmObject As ProModel.CProModel

Set pmObject = CreateObject("ProModel")


pmObject.New

Set pmObject = Nothing


End Sub
ProModel 21
ActiveX

OpenModule
Syntax: OpenModule Module
Description: Opens a specific build module. A module is a table in the ProModel Build menu. Passing a
zero (0) value will close any open modules.
Parameters:
Module (Long) A module ID number from the list below.
Returns: Nothing
Module ID Numbers:
0 No modules open
1 Locations
2 Arrivals
5 Entities
6 Resources
10 Variables
11 Attributes
12 Arrays
15 Function tables
16 Distribution tables
17 Cycle tables
18 Subroutines
19 Processing
24 Path Networks
25 Macros
26 Streams
27 External Files
34 Shift Assignments
36 Background Graphics (Behind grid)
37 Background Graphics (Front of grid)
Example: This example loads a model, then opens the Entities module, as if the user had selected Build
>> Entities.
Sub OpenEntMod()
Dim pmObject As ProModel.CProModel

Set pmObject = CreateObject("ProModel")


pmObject.LoadModel "C:\Program Files\ProModel\Models\Demos\mfg_cost.mod"
pmObject.OpenModule 5

Set pmObject = Nothing


End Sub
22 Chapter 1:
Quit

Quit
Syntax: Quit
Description: Closes ProModel. The “Save Changes?” prompt will appear, if applicable.
Parameters: None
Returns: Nothing
Example: This example opens ProModel, then closes it.
Sub ClosePM()
Dim pmObject As ProModel.CProModel

Set pmObject = CreateObject("ProModel")


pmObject.Quit

Set pmObject = Nothing


End Sub
ProModel 23
ActiveX

RedrawLayout
Syntax: RedrawLayout
Description: Refreshes the layout window. Useful when you add graphical objects via the ProModelData
interface.
Parameters: None
Returns: Nothing
Example: The following examples loads a model, adds a location record, attaches a library graphic to the
location , and redraws the layout.
Sub AddLoc()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim Xpos As Double
Dim Ypos As Double

Set pmObject = CreateObject("ProModel")


Set pmDataObject = CreateObject("ProModelData")
Xpos = 20
Ypos = 20

pmObject.LoadModel "c:\promodel 2001\models\demos\mfg_cost.mod"


pmDataObject.Populate
pmDataObject.AppendRecord pmdTblLocation
pmDataObject.AppendGraphicIcon pmdTblLocation, 1, 1, Xpos, Ypos
pmObject.RedrawLayout

Set pmDataObject = Nothing


Set pmObject = Nothing
End Sub
24 Chapter 1:
RedrawTables

RedrawTables
Syntax: RedrawTables
Description: Refreshes any open tables. When using the ProModel Data Object to update model data, if
the table being update is open, the screen will not show the changes until RedrawTables is executed or the
module is closed and re-opened.
Parameters: None
Returns: Nothing
Example: This example loads a model, adds a new record to the Entities table, then refreshes the table to
show the new record.
Sub AddEnt()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData

Set pmObject = CreateObject("ProModel")


Set pmDataObject = CreateObject("ProModelData")

pmObject.LoadModel "c:\promodel 2001\models\demos\mfg_cost.mod"


pmObject.OpenModule 5
pmDataObject.Populate
pmDataObject.AppendRecord pmdTblEntity
pmDataObject.SetStringFieldValue pmdTblEntity, pmdFldEntName, "MyNewEntity"
pmObject.RedrawTables

Set pmDataObject = Nothing


Set pmObject = Nothing
End Sub

You might also like