Utility and View#

Utility commands are used to do the following:

  • Create SymbolicConstant and Boolean objects.

  • Change the name of a key to a Repository object.

  • Control the use of deprecated commands.

  • Request input from the user.

  • Display status information.

  • Execute Python commands or functions.

  • Register a callback that will be invoked when certain Abaqus Scripting Interface commands are about to be executed.

  • Register a callback that will be invoked when certain Abaqus Scripting Interface objects are about to be deleted.

  • Upgrade Abaqus kernel or GUI scripts from one release of Abaqus to a later release.

View commands are used to transform three-dimensional views stored in Session and Viewport objects to the screen. (See Session object and Viewport object.)

Object features#

AbaqusBoolean#

class AbaqusBoolean(value: int)[source]#

The AbaqusBoolean object is used in a similar way to the SymbolicConstant object. If you pass an AbaqusBoolean object to the Python repr() function, the function returns the text without quotes. In effect, the text is the variable that, by convention, refers to the AbaqusBoolean object. An AbaqusBoolean object has a value of 0 or 1, and an AbaqusBoolean object can be tested in an if statement. You can use an AbaqusBoolean object as an argument to a method in place of 1 or 0. Conversely, you can pass a 0 or a 1 to an Abaqus Scripting Interface method that expects a Boolean argument, and the 0 or 1 will be coerced to the appropriate AbaqusBoolean value. There are only two possible values for an AbaqusBoolean object: 1 and 0. You can import both values from the symbolicConstants module or from the abaqus module. Abaqus Scripting Interface commands that expect an AbaqusBoolean object will also accept a Python bool (True, False), or a Python int (1, 0).

Notes

This object can be accessed by:

from symbolicConstants import *
from abaqusConstants import *

BackwardCompatibility#

class BackwardCompatibility[source]#

The BackwardCompatibility object enables the user to control access to deprecated commands in the Abaqus Scripting Interface and to collect data on which deprecated commands have been used. This enables the user to check that no deprecated methods, members, or arguments have been used. Data are recorded on any deprecated members, methods, or arguments that are used. The BackwardCompatibility object has no constructor. The abaqus module and the odbAccess module each have a member named backwardCompatibility. By default, the value of the includeDeprecated member is ON, and Abaqus will execute a script containing deprecated commands with no indication that you should update the script. You can do either of the following to change the value of the includeDeprecated member and to determine which commands have been deprecated: - From the command line interface in Abaqus/CAE or from an Abaqus Scripting Interface script that is run from within Abaqus/CAE, use the following command:

` backwardCompatibility.setValues(includeDeprecated=OFF) `

  • From an Abaqus Scripting Interface script that is run using abaqus python at the

system prompt, use the following two commands:

` from odbAccess import * backwardCompatibility.setValues(includeDeprecated=OFF) `

In addition, the BackwardCompatibility object provides tools to assist you in determining the deprecated commands that have been used. For example, to determine the deprecated commands used in the script createLug.py, use the following commands: backwardCompatibility.resetDeprecatedMethodsUsed() backwardCompatibility.resetDeprecatedMembersUsed() backwardCompatibility.resetDeprecatedArgsUsed() execfile(‘createLug.py’) print backwardCompatibility.getDeprecatedMethodsUsed() print backwardCompatibility.getDeprecatedMembersUsed() print backwardCompatibility.getDeprecatedArgsUsed()

Notes

This object can be accessed by:

backwardCompatibility
Attributes:
includeDeprecated: Boolean

A Boolean specifying whether deprecated members, methods, and arguments can be seen and used. Possible values are ON and OFF. The default value is ON.

reportDeprecated: Boolean

A Boolean specifying whether a warning is displayed after running a script that contains deprecated commands. The default value is True.

showKeysInReport: Boolean

A Boolean specifying whether the keys and indices are included in the report that is displayed when reportDeprecated is True. The default value is False.

Methods

getDeprecatedArgsUsed()

This method returns a list of deprecated arguments used since the last call to resetDeprecatedArgsUsed.

getDeprecatedMethodsUsed()

This method returns a list of deprecated methods used since the last call to resetDeprecatedMethodsUsed.

resetDeprecatedArgsUsed()

This method clears the list of deprecated arguments used.

resetDeprecatedMethodsUsed()

This method clears the list of deprecated methods used.

setValues([includeDeprecated, ...])

This method modifies the BackwardCompatibility object.

getDeprecatedArgsUsed()[source]#

This method returns a list of deprecated arguments used since the last call to resetDeprecatedArgsUsed.

Returns:
A python:list of Strings.
getDeprecatedMethodsUsed()[source]#

This method returns a list of deprecated methods used since the last call to resetDeprecatedMethodsUsed.

Returns:
A python:list of Strings.
resetDeprecatedArgsUsed()[source]#

This method clears the list of deprecated arguments used.

resetDeprecatedMethodsUsed()[source]#

This method clears the list of deprecated methods used.

setValues(includeDeprecated: BooleanType = 1, reportDeprecated: BooleanType = True, showKeysInReport: BooleanType = False)[source]#

This method modifies the BackwardCompatibility object.

Parameters:
includeDeprecated

A Boolean specifying whether deprecated members, methods, and arguments can be seen and used. The default value is ON.

reportDeprecated

A Boolean specifying whether a warning is displayed after running a script that contains deprecated commands. The default value is True.

showKeysInReport

A Boolean specifying whether the keys and indices are included in the report that is displayed when reportDeprecated is True. The default value is False.

Callback#

These functions execute Python commands or functions.

addImportCallback(moduleName: str, callback: str, userData: str = '')[source]#

This function defines a function to be called when a specified Abaqus/CAE module is imported. You cannot specify a custom module. For more information, see An example of a callback function.

Parameters:
moduleName

A String specifying the name of a specified Abaqus/CAE module.

callback

A Python function to be called. The interface definition of the callback function is :`def functionName(moduleName, userData)`*moduleName* is a String.*userData* is the object passed as the userData argument to the addImportCallback method.

userData

Any Python object or None. This object is passed to the callback function.

Notes

This function can be accessed by:

addImportCallback
removeImportCallback(callback: str, userData: str)[source]#

This function removes a callback added in addImportCallback.

Parameters:
callback

A Python function to be called; it must be the same as the callback argument specified in the original call to addImportCallback.

userData

Any Python object or None; it must be the same as the userData argument specified in the original call to addImportCallback.

Notes

This function can be accessed by:

removeImportCallback

Customization#

The following command is used to record a user-defined command in the Abaqus journal file.

journalMethodCall(objectPath: str, methodName: str, args: tuple, kargs: str)[source]#

This function may be used by a user-defined command to record itself in the Abaqus journal file. For example def setValues( self, **kargs ):

for arg,value in kargs.items():

setattr(arg, value)

from abaqus import journalMethodCall objPath = ‘%s[%r]’ % (self.reposPath, self.name) journalMethodCall(objPath, ‘setValues’, (), kargs)

Note:Your command should not call journalMethodCall if the command changes the mdb using built-in Abaqus Scripting Interface commands, because built-in commands are journaled by default. A command that changes the mdb customData is one example of a command that should call journalMethodCall.

Parameters:
objectPath

A String specifying the path to the object.

methodName

A String specifying the name of the method.

args

A sequence specifying the positional arguments to be written to the journal file.

kargs

A Python dict object specifying the keyword arguments to be written to the journal file.

Notes

This function can be accessed by:

journalMethodCall

Delete#

deleteObjectCallback(callback: str, path: str, userData: str | None = None, includeChildren: BooleanType = False)[source]#

This method adds a callback function that will be invoked when the specified Abaqus Scripting Interface objects are about to be deleted. The callback is invoked only when the object is deleted using the Python statement del object. The callback is not invoked when the object is deleted using an Abaqus Scripting Interface command such as mdb.models[name].parts[name].deleteFeature().

Parameters:
callback

A Python function to be called when an object matching the specified path is about to be deleted. The interface definition of the callback function is:`def functionName(objectPath, userData)`where:objectPath is the path to the object about to be deleted.*userData* is the object passed as the userData argument to the addCallback method.

path

A String specifying the path to an object or the SymbolicConstant ANY. You can include wildcards in the path to specify a pattern to be matched. Examples of valid paths are:`path=’mdb.models[*]’ path=”mdb.models[‘Axle*’].parts[*]” path=’mdb.models[*].materials[*]’ `

userData

Any type of data. This data will be passed to the callback function. The default value is None.

includeChildren

A Boolean specifying that the callback should be called if an object owned by the object specified by the path argument is about to be deleted. The default value is False.

Notes

This function can be accessed by:

deleteObjectCallback.addCallback

Method#

addCallback(caller: str, methodName: str, callback: str, userData: str | None = None, callAfter: BooleanType = 0)[source]#

This method adds a callback function that will be invoked when certain Abaqus/CAE commands are about to be executed.

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.

Notes

This function can be accessed by:

methodCallback.addCallback
removeCallback(caller: str, methodName: str, callback: str, userData: str | None = None)[source]#

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.

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.

Notes

This function can be accessed by:

methodCallback.removeCallback

Repository#

class Repository[source]#

Repositories are containers that store a particular type of object; for example, the steps repository contains all the steps defined in the model. An Abaqus Scripting Interface Repository maps a key to a value. The key is usually a String, and the value is any Python object, usually an Abaqus object. A repository is similar to a Python dictionary; however, only a constructor can add an object to a repository. In addition, all of the objects in a repository are of the same base type. For more information, see Repositories. A Repository has no constructor. Abaqus creates empty repositories when you import a module. For example, Abaqus creates an empty parts repository when you import the part module. The following methods of the Repository object are standard Python dictionary methods and are not described here: The Repository object is derived from the dict object. - has_key - items - keys - values - [changeKey(…)](https://help.3ds.com/2022/english/DSSIMULIA_Established/SIMACAEKERRefMap/simaker-c-utlrepositorypyc.htm?ContextScope=all#simaker-utlrepositorychangekeypyc)

Methods

changeKey(fromName, toName)

This method changes the name of a key in a repository and the name member of the value object.

changeKey(fromName: str, toName: str)[source]#

This method changes the name of a key in a repository and the name member of the value object.

Parameters:
fromName

A String specifying the old name of the repository key.

toName

A String specifying the new name of the repository key.

Status#

SymbolicConstant#

class SymbolicConstant(text: str)[source]#

The SymbolicConstant object represents a string in a way that can be stored in a replay file and used as an argument to Abaqus Scripting Interface methods and functions. By convention the string representation of the SymbolicConstant object is the same as its variable name. If you pass a SymbolicConstant object to the Python repr() function, the function returns the text without quotes. In effect, the text is the variable that, by convention, refers to the SymbolicConstant object. Two SymbolicConstant objects with the same text are the same Python object, although you can assign them to different variables. All of the SymbolicConstant objects that are required in Abaqus Scripting Interface methods are defined in the abaqusConstants module. Some SymbolicConstant objects and the SymbolicConstant constructor are defined in the abaqus module. The SymbolicConstant constructor is also defined in the symbolicConstants module.

Notes

This object can be accessed by:

from symbolicConstants import *
from abaqusConstants import *

Upgrade#

User#

View#

class View(name: str, nearPlane: float, farPlane: float, width: float, height: float, projection: SymbolicConstantType, cameraPosition: tuple, cameraUpVector: tuple, cameraTarget: tuple, viewOffsetX: float, viewOffsetY: float, autoFit: BooleanType, movieMode: BooleanType = 0)[source]#

The Session and Viewport View objects store view settings for custom (both predefined and user-defined) views. The paradigm used to define a view is based on a camera analogy. Similar to taking a photograph with a camera, features such as camera position, view direction, orientation, depth of field, and projection are specified to transform three-dimensional views to the screen. The Layer View objects store a transformation matrix used to position the contents of the Layer within a viewport.

Notes

This object can be accessed by:

session.viewports[name].layers[name].view
session.viewports[name].view
session.views[name]
Attributes:
displayedObjectScreenWidth: float

A Float specifying the width in viewport millimeters of the bounding rectangle around the viewport contents. This value does not include annotations or symbols and it is not clipped to the size of the viewport window.

displayedObjectScreenHeight: float

A Float specifying the height in viewport millimeters of the bounding rectangle around the viewport contents. This value does not include annotations or symbols and it is not clipped to the size of the viewport window.

layerTransform: float

A tuple of Floats specifying a transformation matrix used to position the contents of the Layer within a viewport.

Methods

fitView([drawImmediately])

This method scales the displayable object (such as a part, the assembly, or an X–Y plot) to fit the viewport.

next([drawImmediately])

This method restores the view in the viewport to the next view setting in the list.

pan([xFraction, yFraction, asMovie, ...])

This method pans the view in the viewport using absolute, not relative, mode.

previous([drawImmediately])

This method restores the view in the viewport to the previous view setting in the list.

rotate([xAngle, yAngle, zAngle, mode, ...])

This method rotates the view in the viewport.

setLayerTransform([layerTransform, options, ...])

This method modifies the transformation used to position a Layer.

setProjection(projection[, drawImmediately])

This method modifies the appearance of three-dimensional models in the viewport.

setRotationCenter(rotationCenter)

This method sets the center of rotation to the specified location.

setValues([movieMode])

This method modifies the View object.

setViewpoint(viewVector[, cameraUpVector, ...])

This method sets the camera's position in the viewport.

zoom(zoomFactor[, mode, asMovie, ...])

This method magnifies the view in the viewport.

zoomRectangle(point1, point2[, drawImmediately])

This method fills the viewport with the graphics located within the given rectangle.

fitView(drawImmediately: BooleanType = False)[source]#

This method scales the displayable object (such as a part, the assembly, or an X–Y plot) to fit the viewport.

Parameters:
drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This is typically only used when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

next(drawImmediately: BooleanType = False)[source]#

This method restores the view in the viewport to the next view setting in the list. (There is a list of eight views stored for each viewport.) If there is no next view, no action is taken. Note:This method is not available for a Layer View.

Parameters:
drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This is typically only used when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

pan(xFraction: float = 0, yFraction: float = 0, asMovie: BooleanType = 0, drawImmediately: BooleanType = False)[source]#

This method pans the view in the viewport using absolute, not relative, mode.

Parameters:
xFraction

A Float specifying the amount to pan the model in the screen X-direction as a fraction of the viewport width. A positive value pans the model to the right. A negative value pans the model to the left. The default value is 0.0.

yFraction

A Float specifying the amount to pan the model in the screen Y-direction as a fraction of the viewport height. A positive value pans the model upward. A negative value pans the model downward. The default value is 0.0.

asMovie

A Boolean specifying the alternate mode of the pan view manipulation should be used. The default value is OFF. This argument is ignored for a Layer View.

drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

previous(drawImmediately: BooleanType = False)[source]#

This method restores the view in the viewport to the previous view setting in the list. (There is a list of eight views stored for each viewport.) If there is no previous view, no action is taken. Note:This method is not available for a Layer View.

Parameters:
drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

rotate(xAngle: float = 0, yAngle: float = 0, zAngle: float = 0, mode: SymbolicConstantType = 'MODEL', asMovie: BooleanType = 0, drawImmediately: BooleanType = False)[source]#

This method rotates the view in the viewport. If a center of rotation has been previously specified and asMovie is OFF then this method will honor that rotation center.

Parameters:
xAngle

A Float specifying the degrees to rotate about the X-axis. The default value is 0.0.

yAngle

A Float specifying the degrees to rotate about the Y-axis. The default value is 0.0.

zAngle

A Float specifying the degrees to rotate about the*Z*-axis. The default value is 0.0.

mode

A SymbolicConstant specifying the rotation mode. Possible values are:TOTAL : Set the view to (0, 0, 1), then rotate about the screen’s axes (an absolute rotation).SCREEN : Rotate incrementally about the screen’s axes (a relative rotation).MODEL : Rotate incrementally about the model’s axes (a relative rotation).The default value is MODEL.

asMovie

A Boolean specifying the alternate mode of the rotate view manipulation should be used. The default value is OFF.

drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

setLayerTransform(layerTransform: tuple = (), options: View | None = None, drawImmediately: BooleanType = False)[source]#

This method modifies the transformation used to position a Layer. Note:This method is not available for Session and Viewport Views.

Parameters:
layerTransform

A sequence of 16 Floats specifying the transformation matrix.

options

A View object from which the view settings are to be copied. If the layerTransform argument is also supplied to setLayerTransform, it will override the values in the View object specified by view.

drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

setProjection(projection: SymbolicConstantType, drawImmediately: BooleanType = False)[source]#

This method modifies the appearance of three-dimensional models in the viewport. Choosing PERSPECTIVE makes a model appear more realistic by decreasing the apparent size of features that are farther away from the viewing point. Note:This method is not available for a Layer View.

Parameters:
projection

A SymbolicConstant specifying the projection mode. Possible values are PERSPECTIVE and PARALLEL.

drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

Raises:
RangeError
setRotationCenter(rotationCenter: tuple)[source]#

This method sets the center of rotation to the specified location.

Parameters:
rotationCenter

A sequence of a String and an Int specifying a part instance name and a node label or a sequence of 3 Floats specifying a point.

Raises:
TypeError: rotationCenter cannot be set using a part instance and node label unless the
displayed object is an ODB
setValues(movieMode: BooleanType = 0)[source]#

This method modifies the View object. Note:This method is not available for a Layer View.

Parameters:
movieMode

A Boolean specifying whether or not the camera is in movie mode. The default value is OFF.

Raises:
RangeError
setViewpoint(viewVector: tuple, cameraUpVector: tuple = (), drawImmediately: BooleanType = False)[source]#

This method sets the camera’s position in the viewport. Note:This method is not available for a Layer View.

Parameters:
viewVector

A sequence of three Floats specifying the viewing vector (from the camera to the origin of the model).

cameraUpVector

A sequence of three Floats specifying the camera’s up vector (the screen’s positive Y-axis). The initial value is (0, 0, 0).

drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

zoom(zoomFactor: float, mode: SymbolicConstantType = 'ABSOLUTE', asMovie: BooleanType = 0, drawImmediately: BooleanType = False)[source]#

This method magnifies the view in the viewport.

Parameters:
zoomFactor

A Float specifying the amount to zoom. Possible values are 0.000001 ≤≤ zoomFactor ≤≤ 1000000. A zoomFactor less than one reduces the image. A zoomFactor greater than one enlarges the image.

mode

A SymbolicConstant specifying the way the zoom is executed. Possible values are:ABSOLUTE : Execute fitView, then zoom.RELATIVE : Zoom from the current camera settings.The default value is ABSOLUTE.

asMovie

A Boolean specifying the alternate mode of the zoom view manipulation should be used. The default value is OFF. This argument is ignored for a Layer View.

drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.

Raises:
RangeError
zoomRectangle(point1: tuple[float], point2: tuple[float], drawImmediately: BooleanType = False)[source]#

This method fills the viewport with the graphics located within the given rectangle.

Parameters:
point1

A pair of Floats specifying the*X*- and Y-coordinates of one corner of the rectangle in fractions of the viewport width and height.

point2

A pair of Floats specifying the*X*- and Y-coordinates of the other corner of the rectangle in fractions of the viewport width and height.

drawImmediately

A Boolean specifying the viewport should refresh immediately after the command is processed. This argument is typically used only when writing a script and it is desirable to show intermediate results before the script completes. The default value is False.