This repository has been archived by the owner on Mar 4, 2023. It is now read-only.
/
Method.py
109 lines (90 loc) · 4.41 KB
/
Method.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from abaqusConstants import *
"""The methodCallback module provides functions that allow you to register a callback that
will be invoked when certain Abaqus Scripting Interface commands are about to be
executed. This callback allows you to augment the standard behavior of Abaqus Scripting
Interface commands.
For example, in the following script the myCallback function is executed when the
writeInput method of an object whose type is JobType (in other words, any Job object) is
about to be called:
import methodCallback
from job import JobType
def myCallback(callingObject, arguments, keywordArguments, userData):
print 'An input file is about to be written.'
methodCallback.addCallback(JobType, 'writeInput', myCallback)
Notes
-----
This object can be accessed by:
.. code-block:: python
import methodCallback
"""
def addCallback(
caller: str,
methodName: str,
callback: str,
userData: str = None,
callAfter: Boolean = OFF,
):
"""This method adds a callback function that will be invoked when certain Abaqus/CAE
commands are about to be executed.
Notes
-----
This function can be accessed by:
.. code-block:: python
methodCallback.addCallback
Parameters
----------
caller
An object or type object specifying which object will trigger the callback function to
be invoked or the Symbolic Constant ALL_TYPES.
methodName
A String specifying the name of the method on the caller that will trigger the callback
function to be invoked or the Symbolic Constant ALL_METHODS.
callback
A Python function to be called when a command matching the specified caller and method
name is about to be executed. The interface definition of the callback function is:`def
functionName(callingMethod, args, keywordArgs, userData)`where:*callingMethod* is the
method that called this function.*args* is the sequence of non-keyword arguments that
was passed to the calling method.*keywordArgs* is the dictionary of keyword arguments
that was passed to the calling method.*userData* is the object passed as the *userData*
argument to the addCallback method.
userData
Any type of data. This data will be passed to the callback function. The default value
is None.
callAfter
A Boolean specifying that the callback should be called after the method has executed
(instead of before the method is called). The default value is False, which indicates
that the callback should be called before the method has executed.If *callAfter*=True,
you can also access the return value of the command from within the callback by
including the following statement:`returnValue = getMethodReturnValue()`The
getMethodReturnValue function is in the global namespace of the callback function.
"""
pass
def removeCallback(caller: str, methodName: str, callback: str, userData: str = None):
"""This method removes a callback added by the addCallback method. To successfully remove a
callback, all arguments must exactly match those used when the callback was added.
Notes
-----
This function can be accessed by:
.. code-block:: python
methodCallback.removeCallback
Parameters
----------
caller
An object or type object specifying which object will trigger the callback function to
be invoked or the Symbolic Constant ALL_TYPES.
methodName
A String specifying the name of the method on the caller that will trigger the callback
function to be invoked or the Symbolic Constant ALL_METHODS.
callback
A Python function to be called when a command matching the specified caller and method
name is about to be executed. The interface definition of the callback function is:`def
functionName(callingMethod, args, keywordArgs, userData)`where:*callingMethod* is the
method that called this function.*args* is the sequence of nonkeyword arguments that was
passed to the calling method.*keywordArgs* is the dictionary of keyword arguments that
was passed to the calling method.*userData* is the object passed as the *userData*
argument to the removeCallback method.
userData
Any type of data. This data will be passed to the callback function. The default value
is None.
"""
pass