Oasys.THIS.Utils class

Static methods

classmethod Utils.Ascii85Encode(data, length=Oasys.gRPC.defaultArg)

Encodes an ASCII85 encoded string. This enables binary data to be represented by ASCII characters using five ASCII characters to represent four bytes of binary data (making the encoded size 1/4 larger than the original). By doing this binary data can be stored in JavaScript strings. Note that the method used by THIS to encode and decode strings differs from the standard ASCII85 encoding as that uses the ASCII characters “, ‘ and which cannot be used in JavaScript strings as they have special meanings. The method in THIS uses
0-84 are !-u (ASCII codes 33-117) (i.e. 33 is added to it) with the following exceptions
v is used instead of “ (ASCII code 118 instead of 34)
w is used instead of ‘ (ASCII code 119 instead of 39)
x is used instead of (ASCII code 120 instead of 92)
If all five digits are 0 they are represented by a single character z instead of !!!!!

Parameters:
  • data (ListBuffer) –

    ListBuffer containing the data

  • length (integer) – Optional. Length of data in list buffer to encode. If omitted the whole array buffer will be encoded

Returns:

string

Return type:

str

Example

To encode ListBuffer data:

encoded = Oasys.THIS.Utils.Ascii85Encode(data)
classmethod Utils.Build()

Returns the build number

Returns:

integer

Return type:

int

Example

To get the current build number

build = Oasys.THIS.Utils.Build()
classmethod Utils.CallPromiseHandlers()

Manually call any promise handlers/callbacks in the job queue

Returns:

no return value

Return type:

None

Example

To run any queued promise handlers/callbacks:

Oasys.THIS.Utils.CallPromiseHandlers()
classmethod Utils.CheckinLicense(feature)

Checks a license for a feature back in

Parameters:

feature (string) – feature to check license back in for

Returns:

no return value

Return type:

None

Example

To check in a license for “EXAMPLE”:

Oasys.THIS.Utils.CheckinLicense("EXAMPLE")
classmethod Utils.CheckoutLicense(feature)

Checks out a license for a feature

Parameters:

feature (string) – feature to check license for

Returns:

True if license available, False if not

Return type:

bool

Example

To checkout a license for “EXAMPLE”:

got = Oasys.PRIMER.Utils.CheckoutLicense("EXAMPLE")
if got == False:
    Oasys.PRIMER.Exit()
classmethod Utils.GarbageCollect()

Forces garbage collection to be done. This should not normally need to be called but in exceptional circumstances it can be called to ensure that garbage collection is done to return memory

Returns:

no return value

Return type:

None

Example

To force garbage collection to be done:

Oasys.THIS.Utils.GarbageCollect()
classmethod Utils.HTMLBrowser()

Returns the path to the default HTML browser

Returns:

string of the path

Return type:

str

Example

To get path to the default HTML browser

path = Oasys.THIS.Utils.HTMLBrowser()
classmethod Utils.HiResTimer()

A high resolution timer that can be used to time how long things take. The first time this is called the timer will start and return 0. Subsequent calls will return the time in nanoseconds since the first call. Note that the timer will almost certainly not have 1 nanosecond precision but, depending on the platform, should should have a resolution of at least 1 microsecond. The resolution can be found by using Utils.TimerResolution()

Example

To time how long something takes to nanosecond precision:

start = Oasys.PRIMER.Utils.HiResTimer()
#do something that takes some time...
end = Oasys.PRIMER.Utils.HiResTimer()
classmethod Utils.PdfReader()

Returns the path to the executable of the default pdf reader

Returns:

string of the path

Return type:

str

Example

To get path to the default pdf reader

path = Oasys.THIS.Utils.PdfReader()
classmethod Utils.TimerResolution()

Returns the resolution (precision) of the Utils.HiResTimer() timer in nanoseconds

Example

To find the resolution of the timer in nanoseconds:

resolution = Oasys.THIS.Utils.TimerResolution()
classmethod Utils.Version()

Returns the version number

Returns:

real

Return type:

float

Example

To get the current version number

version = Oasys.THIS.Utils.Version()