43.1.9. Python Syntax considerations

Python has a different syntax than C#/VB. Here are some things to consider when writing the code in it.

  1. The method of importing and using the Toolkit is different.

    C#: Using namespace Functionbay.RecurDyn.ProcessNet.FFlex

    Python: Import RecurDyn.FFlex as FFlex

  2. When type conversion is required in Python, you need to be careful if the value is empty. In the case of C#, even if it is empty via the as syntax, there was a way to try type conversion and return null if it is not possible, but if it is empty in python, an error occurs. Therefore, after confirming this, you need to try type conversion.

    C#: IBNPSubSystem bnpSub = subsystem.BNPSubSystem as IBNPSubSystem

    Python: bnpSub = subsystem.BNPSubSystem

    If bnpSub is not None: bnpSub = IBNPSubSystem(bnpSub)

  3. In the case of an out parameter that returns the value as a C# function (out double, out double), In Python, the return of the value is not applied to the parameter, but is used in the form of using return.

    C#: cylinder.GetBoundingBox(x1, y1 ,z1, x2, y2, z2)

    Python: x1, y1, z1, x2, y2, z2 = cylinder.GetBoundingBox()