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
- addIcon
- addNewMacro
- appFullPath
- appName
- autoLink
- breakLink
- checkout
- checkout2
- closeHTMLViewer
- closeModel
- configureLogging
- createAndInitComponent
- createAssembly
- createAssemblyVariable
- createComponent
- createDataCollector
- createDataExplorer
- createDataHistoryVariable
- createDataMonitor
- createJobManager
- createLink
- createPlugInFrame
- createPlugInFrame2
- createTradeStudy
- destroyPlugInFrame
- displayAboutBox
- displayPreferencesDialog
- dumpComDebug
- exit
- getActiveJobManager
- getAssembly
- getAssemblyStyle
- getComponent
- getDataCollector
- getDataCollectorForDataExplorer
- getDataExplorer
- getDataMonitor
- getFileSystemInfo
- getFormatter
- getGlobalParameters
- getHaltStatus
- getHWND
- getLastErrorMessage
- getLicensingPath
- getLinks
- getLogger
- getMacroScript
- getMacroScriptLanguage
- getMacroTimeout
- getModel
- getModelCenterPath
- getModelUUID
- getNetworkLocations
- getNumUnitCategories
- getNumUnits
- getPreference
- getRunOnlyMode
- getUnitCategoryName
- getUnitName
- getValue
- getValueAbsolute
- getVariable
- getVariableMetaData
- getXMLExtension
- guiCloseAllMultiplexers
- guiLoadFile
- guiSaveModel
- halt
- hidePlugInFrame
- HTMLViewerGetMyHWND
- HTMLViewerWaitForClose
- internalLicensing
- invokeHelp
- IsInteractive
- isOkToClose
- launchDataCollectorPlugIn
- launchHTMLViewer
- launchMacroEditor
- launchTradeStudy
- loadFile
- loadModel
- MessageBox
- modelDirectory
- modelFileName
- moveComponent
- newModel
- parallelInstance
- ProcessID
- removeComponent
- removeDataMonitor
- run
- runAntFile
- runMacro
- SAFEARRAY
- saveModel
- saveModelAs
- saveTradeStudy
- saveVersionedModel
- saveVersionedModelAs
- screenUpdating
- setAlternateParentFrame
- setAssemblyStyle
- setIconPlugInFrame
- setLoginCallback
- setMacroScript
- setMacroScriptLanguage
- setMacroTimeout
- setPassword
- setPreference
- setRunOnlyMode
- setScheduler
- setUserName
- setValue
- setXMLExtension
- showFileBrowseDialog
- showFileSaveDialog
- showPlugInFrame
- startGUIMode
- tradeStudyEnd
- tradeStudyStart
- transformAVPoint
- unAssociatedInstance
- version
Properties
Property modelDirectory
ModelCenter/src/ModelCenter.odl (line 1)
Property screenUpdating
ModelCenter/src/ModelCenter.odl (line 1)
Property modelFileName
ModelCenter/src/ModelCenter.odl (line 1)
Property appName
ModelCenter/src/ModelCenter.odl (line 1)
Property appFullPath
ModelCenter/src/ModelCenter.odl (line 1)
Property IsInteractive
ModelCenter/src/ModelCenter.odl (line 1)
Property ProcessID
ModelCenter/src/ModelCenter.odl (line 1)
Property version
ModelCenter/src/ModelCenter.odl (line 4270)
- 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
Public functions
Function getLastErrorMessage
Function loadFile
- 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).
- BSTR fileName
- [optional] VARIANT onConnectError
Function setValue
- varName: Full ModelCenter path of the variable.
- value: The new value.
- BSTR varName
- BSTR value
Function getValue
- varName: Full ModelCenter path of the variable.
- BSTR varName
Function createComponent
- 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.
- BSTR serverPath
- BSTR name
- BSTR parent
- [optional] VARIANT xPos
- [optional] VARIANT yPos
Function createLink
- variable: Variable to add the link to.
- equation: Equation of the link.
- BSTR variable
- BSTR equation
Function newModel
- modelType:
- [optional] VARIANT modelType
Function saveModel
Function saveModelAs
- fileName: Path to save the Model in.
- BSTR fileName
Function closeModel
Function loadModel
- 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).
- BSTR fileName
- [optional] VARIANT onConnectError
Function getVariable
- name: Full ModelCenter path of the variable.
- BSTR name
Function getComponent
- name: Full ModelCenter path of the Component.
- BSTR name
Function exit
Function createDataCollector
- 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.
- BSTR tradeStudyType
- BSTR setup
Function tradeStudyEnd
Function createJobManager
- 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
- [optional] VARIANT showProgressDialog
Function tradeStudyStart
Function getHaltStatus
Function getModel
Function MessageBox
- msg: Message to display in the MessageBox.
- force:
- BSTR msg
- [optional] VARIANT force
Function getValueAbsolute
- varName: Full ModelCenter path of the variable.
- BSTR varName
Function setScheduler
- scheduler: The scheduler type. Possible types are:
- forward
- backward
- mixed
- script
- BSTR scheduler
Function removeComponent
- name: Full ModelCenter path of the component to remove.
- BSTR name
Function breakLink
- variable: The full ModelCenter path of the variable whose link is to be broken.
- BSTR variable
Function getHWND
Function checkout
- feature: the name of the feature to be checked out
- BSTR feature
Function checkout2
- feature: the name of the feature to be checked out
- productRelease: the release date of the feature being passed
- BSTR feature
- BSTR productRelease
Function runMacro
- macro: The name of the macro to run.
- useMCObject: whether or not to use the ModelCenter object
Parameters:
- BSTR macro
- [optional] VARIANT useMCObject
Function createAssembly
- name: Desired name of the new Assembly.
- parent: Full ModelCenter path of the parent Assembly.
- assemblyType:
- BSTR name
- BSTR parent
- [optional] VARIANT assemblyType
Function createAssemblyVariable
- 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.
- BSTR name
- BSTR type
- BSTR parent
Function autoLink
- srcComp: The source component.
- destComp: The destination component.
- BSTR srcComp
- BSTR destComp
Function getLinks
- reserved: Reserved for future use.
- [optional] VARIANT reserved
Function getModelUUID
Function getFormatter
- format: Specified string format for the Formatter object.
- BSTR format
Function invokeHelp
- pageID:
- long pageID
Function launchTradeStudy
- type: May be a common name, like “doe” or a fully specified URL like “common:\tradestudy\doe”.
- setup:
- BSTR type
- [optional] VARIANT setup
Function createPlugInFrame
- 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.
Parameters:
- BSTR name
- BSTR title
- BSTR reserved
- LPDISPATCH plugIn
- [optional] VARIANT showFavorites
- [optional] VARIANT defaultHeight
- [optional] VARIANT defaultWidth
Function displayAboutBox
Function halt
Function displayPreferencesDialog
Function run
- 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).
- BSTR variableArray
Function getDataMonitor
- component: The desired Component name.
- index: The desired index number (0-based index).
Parameters:
- BSTR component
- VARIANT index
Function createDataMonitor
- 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.
Parameters:
- BSTR component
- BSTR name
- int x
- int y
Function isOkToClose
Function addIcon
- iconFile: The name of the icon file to add.
- BSTR iconFile
Function removeDataMonitor
- 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
- BSTR component
- VARIANT index
Function setUserName
- userName: The user name.
- BSTR userName
Function setPassword
- password: The password.
- BSTR password
Function getModelCenterPath
Function getDataExplorer
- index: The desired index number (0-based index).
- int index
Function getDataCollector
- index: The desired index number (0-based index).
- int index
Function getLogger
Function createPlugInFrame2
- 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.
Parameters:
- BSTR name
- BSTR title
- BSTR reserved
- LPDISPATCH plugIn
- [optional] VARIANT showFavorites
- [optional] VARIANT defaultHeight
- [optional] VARIANT defaultWidth
- [optional] VARIANT minimumHeight
- [optional] VARIANT minimumWidth
Function moveComponent
- component: The component to move.
- parent: Owning object of the component.
- index: Position in the parent.
- BSTR component
- BSTR parent
- [optional] VARIANT index
Function setAssemblyStyle
- assemblyName: The assembly the style will be set.
- style:
- width:
- height:
- BSTR assemblyName
- AssemblyStyle style
- [optional] VARIANT width
- [optional] VARIANT height
Function getAssemblyStyle
- assemblyName: The assembly to retrieve.
- width:
- height:
- BSTR assemblyName
- int * width
- int * height
Function getAssembly
- name: The name of the assembly.
- BSTR name
Function createAndInitComponent
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.
- BSTR serverPath
- BSTR name
- BSTR parent
- BSTR initString
- [optional] VARIANT xPos
- [optional] VARIANT yPos
Function getLicensingPath
Function getMacroScript
- macroName: The name of the macro.
- BSTR macroName
Function setMacroScript
- macroName: The name of the macro.
- script: The script text.
- BSTR macroName
- BSTR script
Function getMacroScriptLanguage
- macroName: The name of the macro.
- BSTR macroName
Function setMacroScriptLanguage
- macroName: The name of the macro.
- language: The macro script language.
- BSTR macroName
- BSTR language
Function addNewMacro
- 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.
- BSTR macroName
- boolean isAppMacro
Function launchMacroEditor
- 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.
- BSTR macroName
Function startGUIMode
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.
- [optional] VARIANT showDialogs
Function getNumUnitCategories
Function getUnitCategoryName
- index: Index of the unit.
- long index
Function getNumUnits
- category: Specified category of units.
- BSTR category
Function getUnitName
- category: Category to retrieve the unit.
- index: Index of the element in the category.
- BSTR category
- long index
Function createTradeStudy
- type: The string identifier for the trade study that should be started.
- setup: The setup string.
- BSTR type
- [optional] VARIANT setup
Function getNetworkLocations
Function saveVersionedModel
- versionStatus: how to go about versioning the model (and its submodels)
- checkinMessage: check-in message to be associated with the model (and its submodels)
- VersionStatus versionStatus
- BSTR checkinMessage
Function saveVersionedModelAs
- 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)
- BSTR fileName
- VersionStatus versionStatus
- BSTR checkinMessage
Function getVariableMetaData
- name: the full name of the variable
- BSTR name
Function dumpComDebug
Function showFileBrowseDialog
- 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
- BSTR title
- [optional] VARIANT filters
- [optional] VARIANT initialUri
- [optional] VARIANT hwnd
Function showFileSaveDialog
- 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
- BSTR title
- int * selectedFilter
- [optional] VARIANT initialFilename
- [optional] VARIANT filters
- [optional] VARIANT initialUri
- [optional] VARIANT hwnd
Function setLoginCallback
- callback: callback to use
- IDispatch * callback
Function createDataHistoryVariable
Function getRunOnlyMode
Function setRunOnlyMode
- shouldBeInRunOnly: true if ModelCenter should be in Run-Only Mode; otherwise, false
- boolean shouldBeInRunOnly
Function createDataExplorer
- 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.
- BSTR tradeStudyType
- BSTR setup
Function getFileSystemInfo
- url: the url for which to load a file system info
- BSTR url
Function SAFEARRAY
- BSTR
Function saveTradeStudy
- 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
- BSTR uri
- int format
- LPDISPATCH dataExplorer
Function getDataCollectorForDataExplorer
- dataExplorerPtr: The Data Explorer pointer for which to retrieve a Data Collector
- LPDISPATCH dataExplorer
Function launchDataCollectorPlugIn
- plugInName: The name of the Data Collector PlugIn to be launched
- dataExplorer: The Data Explorer for which to launch the PlugIn
- BSTR plugInName
- LPDISPATCH dataExplorer
Function guiLoadFile
- fileName: Path of the file to load.
- true: if the save was not canceled
- false: if the save was canceled
- BSTR fileName
Function guiSaveModel
Function getMacroTimeout
- macroName: The name of the macro.
- BSTR macroName
Function setMacroTimeout
- macroName: The name of the macro.
- timeout: The number of seconds to allow a script to run before canceling it; -1 indicates no timeout.
- BSTR macroName
- double timeout
Function guiCloseAllMultiplexers
Private functions
Function setAlternateParentFrame
- long hwnd
Function destroyPlugInFrame
- long hwnd
Function showPlugInFrame
- long hwnd
Function hidePlugInFrame
- long hwnd
Function setIconPlugInFrame
- long hwnd
- BSTR iconFile
Function launchHTMLViewer
- BSTR url
- boolean popup
Function runAntFile
- BSTR fileName
Function getGlobalParameters
Function closeHTMLViewer
- long hwnd
Function HTMLViewerWaitForClose
- long hwnd
Function HTMLViewerGetMyHWND
Function getActiveJobManager
Function getPreference
- preference: (key) value to get value for
Parameters:
- BSTR pref
Function internalLicensing
- BSTR
- long
Function transformAVPoint
- int x
- int y
- boolean screen
- VARIANT * tx
- VARIANT * ty
Function parallelInstance
Function unAssociatedInstance
Function configureLogging
- enableLogging: Set to true to enable the logger.
- boolean enableLogging
Function setXMLExtension
- xml: The XML string.
- BSTR xml
Function getXMLExtension
- nodeName: Name of the XML root tag.
- attributeName: Name of a distinguishing attribute for the XML tag.
- attributeValue: Value of the attribute.
Parameters:
- BSTR nodeName
- BSTR attributeName
- BSTR attributeValue
Function setPreference
- BSTR pref
- BSTR value