Sei sulla pagina 1di 4

Workshop 11

Creating kernel and GUI scripts

Goals
When you complete this workshop, you will be able to transform a replay file into a
kernel script and build a GUI dialog using RSG to run the kernel script. It is
recommended you follow the RSG Dialog Builder tour before starting this workshop.

Tasks
Abaqus/CAE records the commands from the user interface in the replay file. Thus, this
file is a good starting point in creating a kernel script.

1. Start a new session of Abaqus/CAE .


2. Create a 2D Planar part named Plate and sketch a rectangle from 0, 0 to 30,
20. Inscribe a circle with its center at 15, 10 and a radius of 5.
3. Exit Abaqus/CAE without saving the model.
4. In your working directory, rename your session replay file (likely named
abaqus.rpy) to createPlateModule.py.
5. Edit createPlateModule.py with any text editor. Delete all the lines up to but
not including the command to create a sketch (ConstrainedSketch).
6. Create a function named createPlateFunction with the remaining commands.
This function should accept four arguments: partName, width, height and
radius.
7. Change the values of point2 of the command rectangle to use the variables
width and height.
8. Change the values of center of the command CircleByCenterPerimeter to be
width/2 and height/2.
9. Change the values of point1 of the command CircleByCenterPerimeter to be
width/2+radius and height/2.
10. Change every reference to the string 'Plate' to the variable partName.
11. Add the following lines to the top of the module:
from abaqus import *
from abaqusConstants import *

© Dassault Systèmes, 2019 Introduction to Abaqus Scripting


W11.2

12. Your module should look like:

from abaqus import *


from abaqusConstants import *
def createPlateFunction(partName, width, height, radius):
s = mdb.models['Model-1'].ConstrainedSketch(
name='__profile__',
sheetSize=200.0)
g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints
s.setPrimaryObject(option=STANDALONE)
s.rectangle(
point1=(0.0, 0.0),
point2=(width, height))
s.CircleByCenterPerimeter(
center=(width/2.0, height/2.0),
point1=(width/2.0+radius, height/2.0))
p = mdb.models['Model-1'].Part(
name=partName,
dimensionality=TWO_D_PLANAR,
type=DEFORMABLE_BODY)
p = mdb.models['Model-1'].parts[partName]
p.BaseShell(sketch=s)
s.unsetPrimaryObject()
session.viewports['Viewport: 1'].setValues(displayedObject=p)
del mdb.models['Model-1'].sketches['__profile__']

13. Save createPlateModule.py.


14. Start a new session of Abaqus/CAE and launch the RSG Dialog Builder
(Plug-ins→Abaqus→ RSG Dialog Builder).
15. In the first tab (GUI), click Show Dialog and change the title to Create Plate and
press [Enter].

16. Add a group box (click ) with the title Parameters and press [Enter].

17. Add a text field (click ). The label text should be Name: and the keyword
value partName.
18. Add another text field. The label text should be Width (w):, the type should be
Float and the keyword width.
19. Add another text field. The label text should be Height (h):, the type should be
Float and the keyword height.

© Dassault Systèmes, 2019 Introduction to Abaqus Scripting


W11.3

20. Add another text field. The label text should be Radius (r):, the type should be
Float and the keyword radius. Your dialog box should look similar to the
following:

21. Add a second group box (click ) with the title Diagram and press [Enter].
In this group box, add an icon (click ) and select the file createPlate.png
(click to select the file). If necessary, use the arrows ( ) to
position the Diagram group box above the Parameters group box.
22. Your dialog box should look similar to the following:

© Dassault Systèmes, 2019 Introduction to Abaqus Scripting


W11.4

23. Your GUI layout should appear as follows:

24. Switch to the Kernel tabbed page, click Open and select
createPlateModule.py.
25. For the function, select createPlateFunction from the drop-down list.

26. Change to the GUI tabbed page and click to save your plug-in as an RSG
plug-in in the current directory. Enter createPlate as the directory name and
Create Plate… as the menu button name. Note where the plug-in files are saved.
They should be under your current working directory, in a folder named
abaqus_plugins. This will make the plug-in accessible only in Abaqus/CAE
sessions started from this directory. For more generally used plug-ins they should
be stored in the home directory. Furthermore, note that while you can save them
as either an RSG plug-in or a standard plug-in, you can only edit RSG plug-ins
with the RSG dialog builder. You must use a text editor to edit a standard plug-
ins. However, saving an RSG dialog box as a standard plug-in allows an
experienced programmer to extend the dialog's functionality by selecting from the
complete set of Abaqus GUI Toolkit commands.
27. Restart Abaqus/CAE and test the plug-in (Plug-ins→Create Plate). If you want
to edit your plug-in, go to the RSG Builder and open createPlateDB.py.

© Dassault Systèmes, 2019 Introduction to Abaqus Scripting

Potrebbero piacerti anche