Journaling Helper

Description

This library implements a helper that can be used to transfer data between Mechanical and the Project page.

Location

Usage

import wbjn

Functions

ExecuteCommand(api,cmd,**args)

This function executes a journal command specified by cmd You can get a result object by using the function returnValue(obj) in your journal command. All arguments must implement the serialization interface provided by .Net. The object sent to the function returnValue(obj) must also implement the serialization interface. This interface is already implemented for many standard types of data (integer, double, list…). Note that the standard Python dictionary does not implement this interface by default. If a dictionary is required, use the class SerializableDictionary provided by ACT.

The parameter api must be ExtAPI.

ExecuteFile(api,file,**args)

The same as above but executes a journal file specified by file.

Examples

The following commands return 5 as the result:

import wbjn
wbjn.ExecuteCommand(ExtAPI,"returnValue(a+b)",a=2,b=3)

The following commands return My first system is: Static Structural !:

import wbjn
wbjn.ExecuteCommand(ExtAPI,"returnValue(a+GetAllSystems()[0].DisplayText+b)",
a="My first system is: ",b=" !")

The following commands return 3 as the result:

import wbjn
dict = SerializableDictionary[str,int]()
dict.Add("e1",1)
dict.Add("e2",2)
wbjn.ExecuteCommand(ExtAPI,'returnValue(d["e1"]+d["e2"])', d=dict)

Release 18.2 - © ANSYS, Inc. All rights reserved.