Properties

Properties are objects with a name and a value. The value has a data type such as boolean, floating point, integer, vector, enumeration, etc. The typical way to access properties is as follows:

  1. Find MStarComponent in model that contains the property you need to access:

obj = model.Get("Simulation Parameters")

  1. Find the IProperty in this object by category and name:

nx = obj.Get("Space Resolution", "Resolution LX")

Or just using the property name if it is unique:

nx = obj.Get("Resolution LX")

  1. Access the Value of the property object:

value = nx.Value

  1. Change the Value of the property:

nx.Value = 200

Example:

import mstar
model = mstar.Load()
simParams = model.Get("Simulation Parameters")

# Get a property value
runTimeValue = simParams.Get("Run Time").Value

# Set a property value
simParams.Get("Run Time").Value = 123.4

# Get a IChoiceProperty object
stopCondition = simParams.Get("Stop Condition")

# Print current value to screen
print (stopCondition.StrValue)

# Set value
stopCondition.StrValue = "Global Var"

For a more complete example, please see Simple Case

class mstar.IProperty

Base class for all properties

GetName()

Get name of property

GetDisplayName()

Get display name of property

GetDescription()

Get description

class mstar.IChoiceProperty(IProperty)

Property type to access enum based properties that have a limited set of choices

property IntValue: int

Get/set the value by integer. Lookup available values using below method.

property Value: str

Get/set the value by string. Lookup available values using below method.

property StrValue: str

Get/set the value by string. Lookup available values using below method.

property IntChoices: list[int]

Readonly property with int choices

property StrChoices: list[str]

Readonly property with string choices

class mstar.DoubleProperty(IProperty)

Floating point property value

property Value: float
class mstar.BoolProperty(IProperty)

Boolean property value

property Value: bool
class mstar.IntegerProperty(IProperty)

Integer property value

property Value: int
class mstar.StringProperty(IProperty)

String property value

property Value: str
class mstar.ExpressionProperty(IProperty)

Expression property holding an Angelscript expression

property Value: str
property ValueFloat: float

Use this method if you are getting or setting floating point values

class mstar.DirectoryProperty(StringProperty)

String property holding a system path

property Value: str
class mstar.AngelScriptProperty(StringProperty)

Property holding an arbitrary angelscript expression, possibly including multiple user defined functions

property Value: str
class mstar.CudaCodeProperty(StringProperty)

Expression property holding a CUDA NVRTC expression

property Value: str
Validate()

Validate UDF code. Returns errors as string. If string is empty, no errors present

Return type:

str

GetVariables()

Get variables data structure

Return type:

CodeEditorInitObject

GetFunctions()

Get list of function declarations

Return type:

list[str]

class mstar.CodeEditorInitObject
property Inputs

Input variables

Return type:

list[CodeVariableDef]

property Outputs

Output variables

Return type:

list[CodeVariableDef]

class mstar.CodeVariableDef
property Name
Type:

str

property Description
Type:

str

property DisplayGroup
Type:

str

property VariableType
Type:

str

class mstar.NoteProperty(StringProperty)

String property value

property Value: str
class mstar.PointProperty(IProperty)

Point/vector property value of 3 floating point values.

property Value: list[float] must have length 3

For example Value = [ 1.0, 2.0, 0.0 ]

property ValueX: float
property ValueY: float
property ValueZ: float
class mstar.PlacedObjectLocationProperty(IProperty)

Object location accessor property.

Note that it is usually better to access this data using the IPlacedObject interface.

property Value: list[float] must have length 3

For example Value = [ 1.0, 2.0, 0.0 ]

property ValueX: float
property ValueY: float
property ValueZ: float