Skip to main content

ModelCenter scriptWrapper API 2026 R1

PHXString

Last update: 22.06.2026

@PHXClassDecorator(PHXTException_Decorator)

class PHXString(PHXSimpleType)

The ModelCenter type for Strings.

This class adds the following features to the PHXSimpleType:

  • value: String
  • enumValues: String[]
  • enumAliases: String[]

def __init__(self, varName)

  • @param varName: the name of the variable already declared in the wrapper to reference
  • @type varName: string
  • @rtype: void
  varName = checkIsInstance(varName, str)
  self.mcName = varName

def getValue(self)

retrieves the current value of the variable

  • @rtype: string
  return phxPython.strGetValue(self.mcName)

def setValue(self, val)

sets the value for the variable

  • @param val: the value
  • @type val: string
  val = checkIsInstance(val, str)
  phxPython.strSetValue(self.mcName, val)

def toString(self)

converts the variable to a string

  • @rtype: string
  return phxPython.strGetValue(self.mcName)

def fromString(self, val)

converts a String representation to the internal value

  • @param val: the value to convert
  • @type val: string
  • @rtype: void
  val = checkIsInstance(val, str)
  phxPython.strSetValue(self.mcName, val)

def getEnumAliases(self)

Gets the enumeration aliases list

  • @rtype: string[]
  enumAliases = phxPython.strGetEnumAliases(self.mcName).strip()
  if enumAliases != '':
     return enumAliases.split(', ')
  else:
     return []

def setEnumAliases(self, aliases)

Sets the enumeration aliases list

  • @param aliases: An array of strings
  • @type aliases: string (as a comma-separated list) or string[]
  • @rtype: void
  adict = {
    "[": "",
    "]": "",
    "'": "",
  }
  strAliases = multiple_replace(str(aliases), adict)
  phxPython.strSetEnumAliases(self.mcName, strAliases)

def getEnumValues(self)

Gets the enumeration values list

  • @rtype: string[]
  enumValues = phxPython.strGetEnumValues(self.mcName).strip()
  if enumValues != '':
     return enumValues.split(', ')
  else:
     return []

def setEnumValues(self, values)

Sets the enumeration values list

  • @param values: Either a comma-separated list of values or an array of values
  • @type values: string (as a comma-separated list) or string[]
  • @rtype: void
  adict = {
    "[": "",
    "]": "",
    "'": "",
  }
  strVals = multiple_replace(str(values), adict)
  phxPython.strSetEnumValues(self.mcName, strVals)

Connect with Ansys