Let's write a PYTHON🐍 script to create a part in ABAQUS CAE

Create a part in the form of Letter A using Python script.

The script does the following:

  • Creates a new model in the model database.

  • Creates a two-dimensional sketch.

  • Creates a three-dimensional, deformable part.

  • Extrudes the two-dimensional sketch to create the first geometric feature of the part.

  • Creates a new viewport.

  • Displays a shaded image of the new part in the new viewport.

Edu LEARNING Work Showcase 

 

To run the program, do the following:

  1. Start ABAQUS/CAE by typing ABAQUS cae.

  2. From the startup screen, select Run Script .

  3. From the Run Script dialog box that appears, select LetterA.py (or any name you chose)

  4. Click OK to run the script.

#import modules and create a part in the mdb object

from abaqus import *
from abaqusConstants import *
backwardCompatibility.setValues(includeDeprecated=True,
                                reportDeprecated=False)

import sketch
import part

myModel = mdb.Model(name='Model A')

mySketch = myModel.ConstrainedSketch(name='Sketch A',
                                     sheetSize=200.0)

xyCoordsInner = ((-5 , 20), (5, 20), (15, 0),
    (-15, 0), (-5, 20))

xyCoordsOuter = ((-10, 30), (10, 30), (40, -30),
    (30, -30), (20, -10), (-20, -10),
    (-30, -30), (-40, -30), (-10, 30))

for i in range(len(xyCoordsInner)-1):
    mySketch.Line(point1=xyCoordsInner[i],
        point2=xyCoordsInner[i+1])

for i in range(len(xyCoordsOuter)-1):
    mySketch.Line(point1=xyCoordsOuter[i],
        point2=xyCoordsOuter[i+1])

myPart = myModel.Part(name='Part A', dimensionality=THREE_D,
    type=DEFORMABLE_BODY)

myPart.BaseSolidExtrude(sketch=mySketch, depth=20.0)

#Create a part and add a base feature using the sketch
myPart = myModel.Part(name='Part A', dimensionality=THREE_D,
    type=DEFORMABLE_BODY)

myPart.BaseSolidExtrude(sketch=mySketch, depth=20.0)

#Plot themeshed instance in a new viewport

myViewport = session.Viewport(name='Viewport for Model A', origins=(20,20), width=150, height=100)
myViewPort.assemblyDisplay.setValues(renderStyle=SHADED, mesh=ON)
myViewport.setValues(displayedObject=myAssembly)