Skip to main content
Definition: ModelCenter/src/ModelCenter.odl (line 3947) COM instance. ModelCenter batch mode: This example demonstrates invoking ModelCenter and running a Model in batch mode through the COM API. preformatted {"type":"element","name":"preformatted","attributes":{},"children":[{"type":"text","text":"\nDim mc\nSet mc=CreateObject(\"ModelCenter.Application\")\nmc.loadModel \"c:\\testmodel.pxc\"\n'\nDim x\nDim s\nFor x=0 To 10\n mc.setValue \"Model.Linear.x\", x\n s=s & \"x=\" & x & \", y=\" & mc.getValue(\"Model.Linear.y\") & vbNewLine\nNext\nmsgbox s\n"}]} Example ModelCenter Script: This script demonstrates how to automate ModelCenter to create a Model.
First, a new Model is loaded into ModelCenter, two components are instantiated, and then several links are created.
Last, the Model is saved to a .pxc file. preformatted {"type":"element","name":"preformatted","attributes":{},"children":[{"type":"text","text":"\n' This is a test script that automates the creation of a Model\n'\n' -------------------- start "},{"type":"element","name":"ref","attributes":{"kindref":"compound","refid":"namespaceModelCenter"},"children":[{"type":"text","text":"ModelCenter"}]},{"type":"text","text":"\n'\nDim app\nSet app = WScript.CreateObject(\"ModelCenter.Application\")\n'\n' -------------------- start a new Model\n'\napp.newModel\n'\n' -------------------- instantiate a few components\n'\napp.createComponent \"mcre://localhost/Block\", \"block\", \"Model\"\napp.createComponent \"mcre://localhost/Block\", \"block1\", \"Model\"\n'\n' -------------------- create some links\n'\napp.createLink \"Model.block.width\", \"Model.block1.width\"\napp.createLink \"Model.block.height\", \"Model.block1.width + Model.block1.height\"\n'\n' -------------------- save the file\n'\nfile = \"c:\\model.pxc\"\napp.saveModelAs(file)\n"}]}
Example DOE Script: This script demonstrates how to call ModelCenter to perform a DOE.
The script loads a Model into ModelCenter, and then repeatedly sets and gets values to perform the DOE. preformatted {"type":"element","name":"preformatted","attributes":{},"children":[{"type":"text","text":"\n'\n' This is a test script that performs a DOE using "},{"type":"element","name":"ref","attributes":{"kindref":"compound","refid":"namespaceModelCenter"},"children":[{"type":"text","text":"ModelCenter"}]},{"type":"text","text":". To \n' run the script, type \"cscript DOE.vbs\"\n'\n'\n' -------------------- start "},{"type":"element","name":"ref","attributes":{"kindref":"compound","refid":"namespaceModelCenter"},"children":[{"type":"text","text":"ModelCenter"}]},{"type":"text","text":"\n'\nDim app\nSet app = WScript.CreateObject( \"ModelCenter.Application\" )\n'\n' -------------------- load a file\n'\nfile = \"d:\\model.pxc\"\napp.loadFile file\n'\n' -------------------- setup a DOE table\n'\nnumTrials = 4\nnumInputs = 2\nnumOutputs = 2\nDim inputs(2)\ninputs(0) = \"script.VBScript.a\"\ninputs(1) = \"script.VBScript.b\"\nDim outputs(2)\noutputs(0) = \"script.VBScript.c\"\noutputs(1) = \"script.VBScript.d\"\nDim trials(4,2)\ntrials(0,0) = 5\ntrials(0,1) = 2\ntrials(1,0) = 4\ntrials(1,1) = 2\ntrials(2,0) = 5\ntrials(2,1) = 3\ntrials(3,0) = 4\ntrials(3,1) = 3\n'\n' -------------------- perform the runs\n'\n' print a header\nmsg = \"\"\nFor var = 0 To numInputs-1\n msg = msg & inputs(var) & \" \"\nNext\nFor var = 0 To numOutputs-1\n msg = msg & outputs(var) & \" \"\nNext\n' print the values\nWScript.echo msg\n' collect and print values\nFor i = 0 To numTrials-1\n ' create a message\n msg = \"\"\n ' set the input values\n For var = 0 To numInputs-1\n app.setValue inputs(var), trials(i,var)\n msg = msg & trials(i,0) & \" \"\n Next\n ' get the outputs\n For var = 0 To numOutputs-1\n msg = msg & app.getValue( outputs(var) ) & \" \"\n Next\n ' print the values\n WScript.echo msg\nNext\n"}]}

Members

Properties

Property modelDirectory

Definition: ModelCenter/src/ModelCenter.odl (line 1)
Directory of the current Model. If no model is open it will raise an error. If the model has not yet been saved, it will return an empty string. Return type: BSTR

Property screenUpdating

Definition: ModelCenter/src/ModelCenter.odl (line 1)
Whether or not screen updating is turned on. Return type: boolean

Property modelFileName

Definition: ModelCenter/src/ModelCenter.odl (line 1)
The Full path of the current ModelCenter Model. Return type: BSTR

Property appName

Definition: ModelCenter/src/ModelCenter.odl (line 1)
Gets the Application name Returns: Application name Return type: BSTR

Property appFullPath

Definition: ModelCenter/src/ModelCenter.odl (line 1)
Gets the full path to the application. Return type: BSTR

Property IsInteractive

Definition: ModelCenter/src/ModelCenter.odl (line 1)
Is ModelCenter running in interactive/GUI mode. Return type: BOOL

Property ProcessID

Definition: ModelCenter/src/ModelCenter.odl (line 1)
The process identifier of the ModelCenter process. Useful for cases where ModelCenter is running in COM server mode and a client process needs to grant it permission to do something (like move a window to the foreground). Return type: long

Property version

Definition: ModelCenter/src/ModelCenter.odl (line 4270)
Gets the version number of ModelCenter. ModelCenter versions are in the form 5.1.2 where 5 is the major version, 1 is the minor, and 2 is the patch version. Parameters:
  • index: Which part of the version to get.
  • 0 - Get the major version number
  • 1 - Get the minor version number
  • 2 - Get the patch version number
Returns: The requested version part. Return type: long

Public functions

Function getLastErrorMessage

Gets the last error message. Returns: The last error message. Return type: BSTR

Function loadFile

Loads a .pxc file. Parameters:
  • fileName: Path of the .pxc file.
  • onConnectError: States what to do when a connect error is encountered.
    (see OnConnectionErrorMode for error modes, default is CONN_ERR_ERROR).
Parameters:
  • BSTR fileName
  • [optional] VARIANT onConnectError
Return type: void

Function setValue

Sets the value of a variable. Parameters:
  • varName: Full ModelCenter path of the variable.
  • value: The new value.
Parameters:
  • BSTR varName
  • BSTR value
Return type: void

Function getValue

Gets the value of a variable. Parameters:
  • varName: Full ModelCenter path of the variable.
Returns: The value as a variant. Parameters:
  • BSTR varName
Return type: VARIANT

Function createComponent

Creates, or connects, to a new MCRE Component. Parameters:
  • serverPath: The MCRE source path of the new component.
  • name: Name of the new component.
  • parent: Parent assembly of the component.
  • xPos: The x-position in pixels in the Analysis View.
  • yPos: The y-position in pixels in the Analysis View.
Parameters:
  • BSTR serverPath
  • BSTR name
  • BSTR parent
  • [optional] VARIANT xPos
  • [optional] VARIANT yPos
Return type: void

Function createLink

Creates a link to the specified variable based on the specified equation. Parameters:
  • variable: Variable to add the link to.
  • equation: Equation of the link.
Parameters:
  • BSTR variable
  • BSTR equation
Return type: void

Function newModel

Creates a new Model. Parameters:
  • modelType:
Parameters:
  • [optional] VARIANT modelType
Return type: void

Function saveModel

Saves the current Model. Return type: void

Function saveModelAs

Saves the current Model to a specified file. Parameters:
  • fileName: Path to save the Model in.
Parameters:
  • BSTR fileName
Return type: void

Function closeModel

Closes the current Model. Return type: void

Function loadModel

Loads a .pxc file. Parameters:
  • fileName: Path of the .pxc file.
  • onConnectError: States what to do when a connect error is encountered.
    (see OnConnectionErrorMode for error modes, default is CONN_ERR_ERROR).
Parameters:
  • BSTR fileName
  • [optional] VARIANT onConnectError
Return type: void

Function getVariable

Gets a pointer to a variable. Parameters:
  • name: Full ModelCenter path of the variable.
Returns: IDispatch* to an IVariable object. Parameters:
  • BSTR name
Return type: IDispatch *

Function getComponent

Gets a pointer to the Component. Parameters:
  • name: Full ModelCenter path of the Component.
Returns: IDispatch* to an IComponent object. Parameters:
  • BSTR name
Return type: IDispatch *

Function exit

Deprecated. Deprecated: No longer used. Return type: void

Function createDataCollector

Creates a new Data Collector. Parameters:
  • tradeStudyType: Registry ID of the Plug-In. This is obtained by calling the getRegID method of the IAddToModel* object that is passed into the Plug-In’s construct method.
  • setup: A string that is generated from the Plug-In’s “toString” method that can be restored later by the Plug-In’s “fromString” method.
Returns: IDispatch* to an IDataCollector object. Deprecated: use createDataExplorer() instead Parameters:
  • BSTR tradeStudyType
  • BSTR setup
Return type: IDispatch *

Function tradeStudyEnd

Lets ModelCenter know that a Trade Study has been completed. Return type: void

Function createJobManager

Creates a new Job Manager object. Parameters:
  • showProgressDialog: an optional VARIANT that specifies whether or not to show a progress dialog when creating the job manager. Possible values are:
  • true to show a progress dialog and attempt to parent it to ModelCenter
  • false to not show a progress dialog
  • a long value that corresponds to the HWND of the window to which the progress dialog should be parented
Returns: IDispatch* to an IJobManager object. Parameters:
  • [optional] VARIANT showProgressDialog
Return type: IDispatch *

Function tradeStudyStart

Lets ModelCenter know that a Trade Study has been started. Return type: void

Function getHaltStatus

Finds out if the user has pressed the halt button. Returns: yes(TRUE) or no(FALSE). Return type: boolean

Function getModel

Gets a pointer to the Model. Returns: IDispatch* to an IAssembly object. Return type: IDispatch *

Function MessageBox

Creates a MessageBox dialog. Parameters:
  • msg: Message to display in the MessageBox.
  • force:
Parameters:
  • BSTR msg
  • [optional] VARIANT force
Return type: void

Function getValueAbsolute

Gets the value of a variable without validating it. Parameters:
  • varName: Full ModelCenter path of the variable.
Returns: The value as a variant. Parameters:
  • BSTR varName
Return type: VARIANT

Function setScheduler

Sets the current active scheduler for the Model. Parameters:
  • scheduler: The scheduler type. Possible types are:
  • forward
  • backward
  • mixed
  • script
Note: all scheduler types are case sensitive. Parameters:
  • BSTR scheduler
Return type: void

Function removeComponent

Removes the specified component from the Model. Parameters:
  • name: Full ModelCenter path of the component to remove.
Parameters:
  • BSTR name
Return type: void

Function breakLink

Breaks the link to a variable. Parameters:
  • variable: The full ModelCenter path of the variable whose link is to be broken.
Example demonstrating how to break a link:
Parameters:
  • BSTR variable
Return type: void

Function getHWND

Gets the HWND of the current ModelCenter instance. This HWND can then be used as the parent of the Plug-In GUI. Returns: Value of the current HWND instance. Return type: long

Function checkout

Checks out a license feature from FLEXlm Parameters:
  • feature: the name of the feature to be checked out
Returns: an IFeature object Parameters:
  • BSTR feature
Return type: IDispatch *

Function checkout2

Checks out a license feature from FLEXlm Parameters:
  • feature: the name of the feature to be checked out
  • productRelease: the release date of the feature being passed
Returns: an IFeature object Parameters:
  • BSTR feature
  • BSTR productRelease
Return type: IDispatch *

Function runMacro

Runs the specified macro. Parameters:
  • macro: The name of the macro to run.
  • useMCObject: whether or not to use the ModelCenter object
Returns:
Parameters:
  • BSTR macro
  • [optional] VARIANT useMCObject
Return type: VARIANT

Function createAssembly

Creates a new Assembly in the Model. Parameters:
  • name: Desired name of the new Assembly.
  • parent: Full ModelCenter path of the parent Assembly.
  • assemblyType:
Returns: IDispatch* to an IAssembly object. Example demonstrating how to create an Assembly:
Parameters:
  • BSTR name
  • BSTR parent
  • [optional] VARIANT assemblyType
Return type: IDispatch *

Function createAssemblyVariable

Create a new variable in an Assembly. Parameters:
  • name: Desired name of the new variable.
  • type: Type of the new variable. Possible types are:
  • double
  • int
  • boolean
  • string
  • file
  • double[]
  • int[]
  • boolean[]
  • string[]
  • quadfacet
  • surfaceofrevolution
  • nurbs
  • bspline
  • ruled
  • skinned
  • vrml
  • node
  • parent: Full ModelCenter path of the parent Assembly.
Returns: IDispatch* to an IVariable object. Example demonstrating how to create a variable in an existing Assembly:
Parameters:
  • BSTR name
  • BSTR type
  • BSTR parent
Return type: IDispatch *

Function autoLink

Automatically links two components. Parameters:
  • srcComp: The source component.
  • destComp: The destination component.
Parameters:
  • BSTR srcComp
  • BSTR destComp
Return type: void

Function getLinks

Returns a list of all links in the model. Parameters:
  • reserved: Reserved for future use.
Returns: IDispatch* to an IVariableLinks object. Parameters:
  • [optional] VARIANT reserved
Return type: LPDISPATCH

Function getModelUUID

Returns the unique ID string for the current model. Returns: The ID string for the current model. Return type: BSTR

Function getFormatter

Creates a new instance of a formatter which can be used to format numbers to and from a particular string style. See documentation on IPHXFormat.setFormat() for more information on available styles. Parameters:
  • format: Specified string format for the Formatter object.
Returns: An IDispatch* to the IPHXFormat object. Parameters:
  • BSTR format
Return type: IDispatch *

Function invokeHelp

Invokes the specified context sensitive help item out of the ModelCenter help file. Parameters:
  • pageID:
Parameters:
  • long pageID
Return type: void

Function launchTradeStudy

Causes the specified Trade Study tool to be launched. Parameters:
  • type: May be a common name, like “doe” or a fully specified URL like “common:\tradestudy\doe”.
  • setup:
Parameters:
  • BSTR type
  • [optional] VARIANT setup
Return type: void

Function createPlugInFrame

Creates a new frame window with favorites in it which can be used by Plug-Ins as a parent window in order to integrate with ModelCenter closer and to get favorites. Currently only supports C++ Plug-Ins. Parameters:
  • name: The programmatic name of the plug-in. This is used to store favorites and settings uniquely.
  • title: The title to put on the frame
  • reserved: Reserved, must be blank
  • plugIn: An IDispatch to the plug-in, used to get at the to/from string to use with favorites.
  • showFavorites:
  • defaultHeight: The default height of the frame.
  • defaultWidth: The default width of the frame.
Returns:
Parameters:
  • BSTR name
  • BSTR title
  • BSTR reserved
  • LPDISPATCH plugIn
  • [optional] VARIANT showFavorites
  • [optional] VARIANT defaultHeight
  • [optional] VARIANT defaultWidth
Return type: long

Function displayAboutBox

Display the “About” dialog for ModelCenter. Return type: void

Function halt

Stop execution of the Model currently running in ModelCenter. Return type: void

Function displayPreferencesDialog

Display the “Preferences” dialog for ModelCenter. Return type: void

Function run

Runs a specified set of variables in the current Model. Parameters:
  • variableArray: A comma-separated list of ModelCenter variables to validate.
    If no variables are specified then the entire model will be run (equivalent to clicking the scheduler run button).
Parameters:
  • BSTR variableArray
Return type: void

Function getDataMonitor

Retrieves the indexed Data Monitor associated with the specified Component. Parameters:
  • component: The desired Component name.
  • index: The desired index number (0-based index).
Returns:
Parameters:
  • BSTR component
  • VARIANT index
Return type: IDispatch *

Function createDataMonitor

Creates a Data Monitor associated with a particular component. Parameters:
  • component: The name of the ModelCenter component to associate the Data Monitor with.
  • name: The name of the Data Monitor.
  • x: The x-position of the Data Monitor.
  • y: The y-position of the Data Monitor.
Returns:
Parameters:
  • BSTR component
  • BSTR name
  • int x
  • int y
Return type: IDispatch *

Function isOkToClose

Determines whether any sub-windows are currently open in ModelCenter. Returns: True if no sub windows are open, else false. Return type: boolean

Function addIcon

Adds a given icon file to the list of icons known by model. Parameters:
  • iconFile: The name of the icon file to add.
Returns: The index of the icon in ModelCenter’s icon list. Parameters:
  • BSTR iconFile
Return type: short

Function removeDataMonitor

Remove a specific data monitor associated with a particular component Parameters:
  • component: the name of the component under which to find the data monitor for deletion
  • index: the integer index (0-based index) or string title of the data monitor being removed
Returns: whether the data monitor was successfully found and deleted Parameters:
  • BSTR component
  • VARIANT index
Return type: boolean

Function setUserName

Sets the user name that ModelCenter will use for authentication. Parameters:
  • userName: The user name.
Parameters:
  • BSTR userName
Return type: void

Function setPassword

Sets the password that ModelCenter will use for authentication. Parameters:
  • password: The password.
Parameters:
  • BSTR password
Return type: void

Function getModelCenterPath

Returns the full path to where ModelCenter is installed. Returns: Full file path where ModelCenter is installed. Return type: BSTR

Function getDataExplorer

Gets a pointer to the specified Data Explorer. Parameters:
  • index: The desired index number (0-based index).
Returns: IDispatch* to an IDataExplorer object. Parameters:
  • int index
Return type: IDispatch *

Function getDataCollector

Gets a pointer to the specified Data Collector. Parameters:
  • index: The desired index number (0-based index).
Returns: IDispatch* to an IDataCollector object. Parameters:
  • int index
Return type: IDispatch *

Function getLogger

Gets the ILogger object used by ModelCenter for logging status and error messages. Returns: IDispatch* to an ILogger object. Return type: IDispatch *

Function createPlugInFrame2

Creates a new frame window with favorites in it which can be used by Plug-Ins as a parent window in order to integrate with ModelCenter closer and to get favorites. Currently only supports C++ Plug-Ins. Parameters:
  • name: The programmatic name of the plug-in. This is used to store favorites and settings uniquely.
  • title: The title to put on the frame
  • reserved: Reserved, must be blank
  • plugIn: An IDispatch to the plug-in, used to get at the to/from string to use with favorites.
  • showFavorites:
  • defaultHeight: The default height of the frame.
  • defaultWidth: The default width of the frame.
  • minimumHeight: The minimum allowed height of the frame.
  • minimumWidth: The minimum allowed width of the frame.
Returns:
Parameters:
  • BSTR name
  • BSTR title
  • BSTR reserved
  • LPDISPATCH plugIn
  • [optional] VARIANT showFavorites
  • [optional] VARIANT defaultHeight
  • [optional] VARIANT defaultWidth
  • [optional] VARIANT minimumHeight
  • [optional] VARIANT minimumWidth
Return type: long

Function moveComponent

Moves the component to the parent at the given index. Parameters:
  • component: The component to move.
  • parent: Owning object of the component.
  • index: Position in the parent.
Parameters:
  • BSTR component
  • BSTR parent
  • [optional] VARIANT index
Return type: void

Function setAssemblyStyle

Sets the assembly style of the component (collapse, expanded, N^2, etc). Parameters:
  • assemblyName: The assembly the style will be set.
  • style:
  • width:
  • height:
Parameters:
  • BSTR assemblyName
  • AssemblyStyle style
  • [optional] VARIANT width
  • [optional] VARIANT height
Return type: void

Function getAssemblyStyle

Gets the style of the assembly (Collapsed, expanded, N^2, etc). Parameters:
  • assemblyName: The assembly to retrieve.
  • width:
  • height:
Returns: AssemblyStyle Parameters:
  • BSTR assemblyName
  • int * width
  • int * height
Return type: AssemblyStyle

Function getAssembly

Gets the assembly by the given name. Parameters:
  • name: The name of the assembly.
Returns: IDispatch* to an IAssembly object. Parameters:
  • BSTR name
Return type: IDispatch *

Function createAndInitComponent

Creates a new component and initializes it from string data. ?> This method can only be invoked on plug-ins which support IComponentPlugin.fromString(). Furthermore, it should only be used when you know exactly the format that is expected by the component’s fromString() method. It is designed to be used from plug-ins in third-party software which need to initialize a matching component to connect to that software in the model.

Ideally, both the plug-in for the third-party software and the ModelCenter component will share the same codebase, so you can generate the configuration string from the same code which you will use to process it later. Mismatch between formats will almost certainly cause this method to fail. Parameters:
  • serverPath: The server path, e.g. “mcre:\localhost\block”. You can get examples of server paths by looking at the component properties for existing ModelCenter components.
  • name: The name of the new component.
  • parent: The parent component.
  • initString: The initialization string for the component. If NULL, the behavior of this function is identical to createComponent().
  • xPos: The X position.
  • yPos: The Y position.
Returns: The newly created IComponent object Parameters:
  • BSTR serverPath
  • BSTR name
  • BSTR parent
  • BSTR initString
  • [optional] VARIANT xPos
  • [optional] VARIANT yPos
Return type: IDispatch *

Function getLicensingPath

Gets the licensing path used by ModelCenter. By default the path is the base ModelCenter install directory. Returns: Return type: BSTR

Function getMacroScript

Gets a macro script ?> This method is not safe for use from a component in parallel mode and will throw an exception if used in such a manner. Parameters:
  • macroName: The name of the macro.
Returns: A string representing the macro script. Parameters:
  • BSTR macroName
Return type: BSTR

Function setMacroScript

Sets a macro script ?> This method is not safe for use from a component in parallel mode and will throw an exception if used in such a manner. Parameters:
  • macroName: The name of the macro.
  • script: The script text.
Parameters:
  • BSTR macroName
  • BSTR script
Return type: void

Function getMacroScriptLanguage

Gets a macro script language ?> This method is not safe for use from a component in parallel mode and will throw an exception if used in such a manner. Parameters:
  • macroName: The name of the macro.
Returns: A string representing the macro script language. Parameters:
  • BSTR macroName
Return type: BSTR

Function setMacroScriptLanguage

Sets the language for a macro script ?> This method is not safe for use from a component in parallel mode and will throw an exception if used in such a manner. Parameters:
  • macroName: The name of the macro.
  • language: The macro script language.
Parameters:
  • BSTR macroName
  • BSTR language
Return type: void

Function addNewMacro

Adds a new macro Parameters:
  • macroName: The name of the macro to show in the editor.
  • isAppMacro: If true, the new macro will be an application macro. Otherwise, the new macro will be a model macro.
Parameters:
  • BSTR macroName
  • boolean isAppMacro
Return type: void

Function launchMacroEditor

Launches the macro editor tool, and show the macro script corresponding to macroName Parameters:
  • macroName: the name of the macro to show in the editor. Just show the editor if the argument is null, or is not a valid macro name.
Parameters:
  • BSTR macroName
Return type: void

Function startGUIMode

THIS FUNCTION IS A BETA CAPABILITY Normally when invoked via COM, ModelCenter is in “server” mode and it hides all GUI and dialogs. This method can be invoked immediately after instantiating the ModelCenter object to cause the GUI to be displayed.
Calling this method at any other time than immediately after creating the ModelCenter object is NOT SUPPORTED. Strange behavior or even crashes will likely ensue if it is called at any other time. Once this method is invoked, ModelCenter may pop up GUI dialogs requiring user interaction at any time. This means your script may hang indefinitely if a user is not there to click through. For example, if a component fails to load on model load, the user would be prompted with the failed component dialog and the loadModel() api function would hang until the user answered the dialog. Parameters:
  • showDialogs: Boolean, that if true, will allow showing of startup dialogs such as the ‘Recover Trade Study’ dialog or ‘Welcome to ModelCenter’ dialog.
Parameters:
  • [optional] VARIANT showDialogs
Return type: void

Function getNumUnitCategories

Returns the number of unit categories in the IModelCenter object. Returns: The number for unit categories, or -1 if there is an error. Return type: long

Function getUnitCategoryName

Returns the name of the category of a unit. Parameters:
  • index: Index of the unit.
Returns: The name of the category, or empty string if there is an error. Parameters:
  • long index
Return type: BSTR

Function getNumUnits

Returns the number of units inside a specified category. Parameters:
  • category: Specified category of units.
Returns: The number of units, or -1 if there is an error. Parameters:
  • BSTR category
Return type: long

Function getUnitName

Gets the name of the unit. Parameters:
  • category: Category to retrieve the unit.
  • index: Index of the element in the category.
Returns: The name of the unit, or empty string if there is an error. Parameters:
  • BSTR category
  • long index
Return type: BSTR

Function createTradeStudy

Launches the specified trade study. Parameters:
  • type: The string identifier for the trade study that should be started.
  • setup: The setup string.
Returns: An IDispatch* to the trade study object. Parameters:
  • BSTR type
  • [optional] VARIANT setup
Return type: IDispatch *

Function getNetworkLocations

Return a reference to the Network Locations object Returns: An IDispatch* to the INetworkLocations object. Return type: IDispatch *

Function saveVersionedModel

Saves the current Model. Parameters:
  • versionStatus: how to go about versioning the model (and its submodels)
  • checkinMessage: check-in message to be associated with the model (and its submodels)
Parameters: Return type: void

Function saveVersionedModelAs

Saves the current Model to a specified file. Parameters:
  • fileName: Path to save the Model in.
  • versionStatus: how to go about versioning the submodel (and its submodels)
  • checkinMessage: check-in message to be associated with the model (and its submodels)
Parameters: Return type: void

Function getVariableMetaData

Get metadata from a variable. Throws an exception if the variable is not found. Parameters:
  • name: the full name of the variable
Returns: the metadata, in the form of an IDHVariable (from PHXDATAHISTORYLib) Parameters:
  • BSTR name
Return type: LPDISPATCH

Function dumpComDebug

Dump COM debug information to TRACE(); only has an effect in debug builds. Return type: void

Function showFileBrowseDialog

Displays file selection for loading dialog and returns URI of selected file. Parameters:
  • title: title of dialog window
  • filters: array of file type filters
  • initialUri: initialUri to use in dialog
  • hwnd: the window handle to which to parent the dialog
Returns: URI of selected file, or empty string if none selected Parameters:
  • BSTR title
  • [optional] VARIANT filters
  • [optional] VARIANT initialUri
  • [optional] VARIANT hwnd
Return type: BSTR

Function showFileSaveDialog

Displays file selection for saving dialog and returns URI of selected file. Parameters:
  • title: title of dialog window
  • selectedFilter: the number of the filter selected
  • initialFilename: the filename to populate the save dialog with
  • filters: array of file type filters
  • initialUri: initialUri to use in dialog
  • hwnd: the window handle to which to parent the dialog
Returns: URI of selected file, or empty string if none selected Parameters:
  • BSTR title
  • int * selectedFilter
  • [optional] VARIANT initialFilename
  • [optional] VARIANT filters
  • [optional] VARIANT initialUri
  • [optional] VARIANT hwnd
Return type: BSTR

Function setLoginCallback

Sets the login callback to use for authentication. Parameters:
  • callback: callback to use
Parameters:
  • IDispatch * callback
Return type: void

Function createDataHistoryVariable

Create an IDHVariable object. Return type: IDispatch *

Function getRunOnlyMode

Gets the status of ModelCenter being in Run-Only Mode. Returns: true if ModelCenter is in Run-Only Mode; otherwise, false Return type: boolean

Function setRunOnlyMode

Sets the status of ModelCenter being in Run-Only Mode to the specified value. Note: This function can only be called if it is the first function to be called on a new ModelCenter object; otherwise, it will throw an exception. This is to ensure that the correct ModelCenter license is checked out. Parameters:
  • shouldBeInRunOnly: true if ModelCenter should be in Run-Only Mode; otherwise, false
Parameters:
  • boolean shouldBeInRunOnly
Return type: void

Function createDataExplorer

Creates a new Data Explorer. This documentation assumes you’re creating it for a trade study; if you’re not you can pass almost anything in for tradeStudyType or setup. Parameters:
  • tradeStudyType: Registry ID of the Plug-In. This is obtained by calling the getRegID method of the IAddToModel* object that is passed into the Plug-In’s construct method.
  • setup: A string that is generated from the Plug-In’s “toString” method that can be restored later by the Plug-In’s “fromString” method.
Returns: IDispatch* to an PHXDATAEXPLORERLib::_DPHXDataExplorer object. Parameters:
  • BSTR tradeStudyType
  • BSTR setup
Return type: IDispatch *

Function getFileSystemInfo

Gets the FileSystemInfo for a given URL. Parameters:
  • url: the url for which to load a file system info
Parameters:
  • BSTR url
Return type: IDispatch *

Function SAFEARRAY

Returns an array containing a list of FileDialog filters for ModelCenter trade study files. Returns: SAFEARRAY of filters for use in FileDialog of the files used by trade studies Parameters:
  • BSTR
Return type:

Function saveTradeStudy

Save the trade study currently loaded in the DataExplorer to the given URI. It will overwrite the file if it exists. Note: Saving in pxt/pxtz formats will only save legacy plots and not the new plot types. Use tstudy(TS_FORMAT_TSTUDY) format to save all plots. Parameters:
  • uri: the uri to write the trade study to
  • format: the file format to be used when saving the trade study. Must be set to TS_FORMAT_TSTUDY. See TradeStudyFormat enumeration.
  • dataExplorer: the data explorer from which to take trade study data
Parameters:
  • BSTR uri
  • int format
  • LPDISPATCH dataExplorer
Return type: void

Function getDataCollectorForDataExplorer

Retrieves a pointer to the Data Collector for the specified Data Explorer. Parameters:
  • dataExplorerPtr: The Data Explorer pointer for which to retrieve a Data Collector
Returns: IDispatch* to the IDataCollector object for the specified Data Explorer Parameters:
  • LPDISPATCH dataExplorer
Return type: IDispatch *

Function launchDataCollectorPlugIn

Launches a specific Data Collector PlugIn, by name, on the specified Data Explorer. Parameters:
  • plugInName: The name of the Data Collector PlugIn to be launched
  • dataExplorer: The Data Explorer for which to launch the PlugIn
Parameters:
  • BSTR plugInName
  • LPDISPATCH dataExplorer
Return type: void

Function guiLoadFile

Loads a file in “GUI” mode, that is, unlike loadFile(…), will produce a prompt to the user to verify whether or not any currently opened model should be saved prior to loading the given file. Parameters:
  • fileName: Path of the file to load.
Return values:
  • true: if the save was not canceled
  • false: if the save was canceled
Parameters:
  • BSTR fileName
Return type: boolean

Function guiSaveModel

Saves the currently open file in “GUI” mode; unlike saveModel, this can pop up a save dialog (if the file has not already been saved). It will use ModelCenter’s logic to determine what to do about versioned files. Return type: void

Function getMacroTimeout

Gets a macro’s timeout. ?> This method is not safe for use from a component in parallel mode and will throw an exception if used in such a manner. Parameters:
  • macroName: The name of the macro.
Returns: Number of seconds to allow a script to run before canceling it; -1 indicates no timeout. Parameters:
  • BSTR macroName
Return type: double

Function setMacroTimeout

Sets a macro’s timeout. ?> This method is not safe for use from a component in parallel mode and will throw an exception if used in such a manner. Parameters:
  • macroName: The name of the macro.
  • timeout: The number of seconds to allow a script to run before canceling it; -1 indicates no timeout.
Parameters:
  • BSTR macroName
  • double timeout
Return type: void

Function guiCloseAllMultiplexers

Attempts to close the DataExplorers of all vizualization multiplexers. Returns: true if the user allowed all multiplexers to close. Return type: boolean

Private functions

Function setAlternateParentFrame

Parameters:
  • long hwnd
Return type: void

Function destroyPlugInFrame

Parameters:
  • long hwnd
Return type: void

Function showPlugInFrame

Parameters:
  • long hwnd
Return type: void

Function hidePlugInFrame

Parameters:
  • long hwnd
Return type: void

Function setIconPlugInFrame

Parameters:
  • long hwnd
  • BSTR iconFile
Return type: void

Function launchHTMLViewer

Parameters:
  • BSTR url
  • boolean popup
Return type: long

Function runAntFile

Parameters:
  • BSTR fileName
Return type: void

Function getGlobalParameters

Return type: IDispatch *

Function closeHTMLViewer

Parameters:
  • long hwnd
Return type: boolean

Function HTMLViewerWaitForClose

Parameters:
  • long hwnd
Return type: void

Function HTMLViewerGetMyHWND

Return type: long

Function getActiveJobManager

Return type: IDispatch *

Function getPreference

Gets preference value for the given key (pref). Note: Parses preference value in following order: Bool -> long -> double -> string Parameters:
  • preference: (key) value to get value for
Returns: preference value as a variant.
Parameters:
  • BSTR pref
Return type: VARIANT

Function internalLicensing

Parameters:
  • BSTR
  • long
Return type: void

Function transformAVPoint

Parameters:
  • int x
  • int y
  • boolean screen
  • VARIANT * tx
  • VARIANT * ty
Return type: void

Function parallelInstance

Return type: IDispatch *

Function unAssociatedInstance

Return type: IDispatch *

Function configureLogging

Configures the ModelCenter logger, currently used for testing. Parameters:
  • enableLogging: Set to true to enable the logger.
Parameters:
  • boolean enableLogging
Return type: void

Function setXMLExtension

Adds the XML as an XML extension node to the model file. Parameters:
  • xml: The XML string.
Parameters:
  • BSTR xml
Return type: void

Function getXMLExtension

Gets an XML extension node from the model file that matches the specified query. Parameters:
  • nodeName: Name of the XML root tag.
  • attributeName: Name of a distinguishing attribute for the XML tag.
  • attributeValue: Value of the attribute.
Returns:
Parameters:
  • BSTR nodeName
  • BSTR attributeName
  • BSTR attributeValue
Return type: BSTR

Function setPreference

Parameters:
  • BSTR pref
  • BSTR value
Return type: void