Skip to main content

ModelCenter APIs 2025 R1

Interface ModelCenter::IScriptComponent

Last update: 16.07.2025

Definition: ModelCenter/src/ModelCenter.odl (line 1395)

COM Instance.

Inherits from:

Members

Properties

Property Variables

Definition: ModelCenter/src/ModelCenter.odl (line 1)

VARIANT ModelCenter::IScriptComponent::Variables

Return type: VARIANT

Property Groups

Definition: ModelCenter/src/ModelCenter.odl (line 1)

VARIANT ModelCenter::IScriptComponent::Groups

Return type: VARIANT

Property userData

Definition: ModelCenter/src/ModelCenter.odl (line 1)

VARIANT ModelCenter::IScriptComponent::userData

Return type: VARIANT

Property AssociatedFiles

Definition: ModelCenter/src/ModelCenter.odl (line 1)

VARIANT ModelCenter::IScriptComponent::AssociatedFiles

Return type: VARIANT

Property IndexInParent

Definition: ModelCenter/src/ModelCenter.odl (line 1)

int ModelCenter::IScriptComponent::IndexInParent

Return type: int

Property ParentAssembly

Definition: ModelCenter/src/ModelCenter.odl (line 1)

LPDISPATCH ModelCenter::IScriptComponent::ParentAssembly

Return type: LPDISPATCH

Property language

Definition: ModelCenter/src/ModelCenter.odl (line 1)

BSTR ModelCenter::IScriptComponent::language

The script language. Must be set prior to setting the source.

Return type: BSTR

Property timeout

Definition: ModelCenter/src/ModelCenter.odl (line 1)

double ModelCenter::IScriptComponent::timeout

The script timeout in seconds. Use -1 to set no timeout.

Return type: double

Property forwardSchedule

Definition: ModelCenter/src/ModelCenter.odl (line 1)

boolean ModelCenter::IScriptComponent::forwardSchedule

True to run the component in forward scheduling mode.

Return type: boolean

Property prevalidate

Definition: ModelCenter/src/ModelCenter.odl (line 1)

boolean ModelCenter::IScriptComponent::prevalidate

True to pre-validate the component.

Return type: boolean

Public functions

Function getName

BSTR ModelCenter::IScriptComponent::getName()

Gets the name of the Component.

Returns:

The name of the Component.

Return type: BSTR

Reimplements: getName

Function getFullName

BSTR ModelCenter::IScriptComponent::getFullName()

Gets the full ModelCenter path of the Component.

Returns:

the full ModelCenter path of the Component.

Return type: BSTR

Reimplements: getFullName

Function run

void ModelCenter::IScriptComponent::run()

Runs the Component.

Return type: void

Reimplements: run

Function getSource

BSTR ModelCenter::IScriptComponent::getSource()

Gets the source of the Component.

Returns:

The source of the Component.

Return type: BSTR

Reimplements: getSource

Function invokeMethod

void ModelCenter::IScriptComponent::invokeMethod(BSTR method)

Invokes one of the Component's methods.

Parameters:

  • method: The name of the method to invoke.

Parameters:

  • BSTR method

Return type: void

Reimplements: invokeMethod

Function invalidate

void ModelCenter::IScriptComponent::invalidate()

Invalidates the Component and all of its variables.

Return type: void

Reimplements: invalidate

Function reconnect

void ModelCenter::IScriptComponent::reconnect()

Reconnect a Component.

Return type: void

Reimplements: reconnect

Function downloadValues

void ModelCenter::IScriptComponent::downloadValues()

Downloads the component's variable values from ModelCenter Remote Execution, if it's a MCRE component.

Return type: void

Reimplements: downloadValues

Function getVariable

LPDISPATCH ModelCenter::IScriptComponent::getVariable(BSTR name)

Gets the Variable by the specified name.

Parameters:

  • name: The name of the variable to retrieve in dotted notation relative to the Component.

Returns:

IDispatch* to an IVariable object.

Parameters:

  • BSTR name

Return type: LPDISPATCH

Reimplements: getVariable

Function getPositionX

int ModelCenter::IScriptComponent::getPositionX()

Return type: int

Reimplements: getPositionX

Function getPositionY

int ModelCenter::IScriptComponent::getPositionY()

Return type: int

Reimplements: getPositionY

Function rename

void ModelCenter::IScriptComponent::rename(BSTR name)

Renames the current Component.

Parameters:

  • name: New name of the Component.

Parameters:

  • BSTR name

Return type: void

Reimplements: rename

Function getType

BSTR ModelCenter::IScriptComponent::getType()

Gets the type of the component. Valid types include:

  • Component

  • Assembly

  • Sequence

  • If

  • Parallel

  • Empty

  • ForEach

Returns:

The type of the component.

Return type: BSTR

Reimplements: getType

Function show

void ModelCenter::IScriptComponent::show()

Show the GUI form associated with the component, if any.

Return type: void

Reimplements: show

Function setSourceFromString

void ModelCenter::IScriptComponent::setSourceFromString(BSTR script)

Sets the source script code of the script component to the given string. The source code is parsed baesd on the current language setting. The script language should be set before calling this function. Parameters:

  • script: string value to use as the script code

Parameters:

  • BSTR script

Return type: void

Function setSourceFromFile

void ModelCenter::IScriptComponent::setSourceFromFile(BSTR file)

Sets the source script code of the script component to the contents of the file. The source code is parsed baesd on the current language setting. The script language should be set before calling this function. Parameters:

  • file: the full path of the file

Parameters:

  • BSTR file

Return type: void

Function addVariable

LPDISPATCH ModelCenter::IScriptComponent::addVariable(BSTR name, BSTR type, BSTR state)

Adds the variable to the component. Parameters:

  • name: the name of the variable
  • type: the type of the variable e.x. "double", "string[]", "object", etc
  • state: the state of the variable e.x. "input", "output"

Returns:

the IVariable object of the newly created variable

Parameters:

  • BSTR name
  • BSTR type
  • BSTR state

Return type: LPDISPATCH

Function removeVariable

void ModelCenter::IScriptComponent::removeVariable(BSTR name)

Removes the variable from the component. Parameters:

  • name: the name of the variable to remove

Parameters:

  • BSTR name

Return type: void

Function setVariables

void ModelCenter::IScriptComponent::setVariables(VARIANT inputs, BSTR outputs)

Sets the variables of the component. Previous variables of this component are removed. Parameters:

  • inputs: comma separated list of input variables e.x. "long n, double[] p, ..."
  • outputs: comma separated list of output variables e.x. "double x, string y, ..."

Parameters:

  • VARIANT inputs
  • BSTR outputs

Return type: void

Function getSourceScript

BSTR ModelCenter::IScriptComponent::getSourceScript()

Gets the source script code of the script component. Returns:

the source script

Return type: BSTR

Connect with Ansys