-1

Preparing a code to do a parametric analysis. When I do the modelling in abaqus cae, while creating datum/reference axis/point, it uses a datum number. When I further copy and paste that code through "run script", I always end up with KeyError. Any suggestions/references to work with datum plane, datum axis in scripting.

Tyring to prepare a script to perform parametric modelling. For that, I used datum plane, and axis in the modelling. abaqus used datum[] to define the selected entities. However, if I rerun the code, it ended uup with KeyError. It also happened with the number inside the brackets of edges, faces, and datum. The below code is working, as it has simple geoemtry. When I work with multiple parts, the number inside the bracket of datums are varying. So, if i change the dimension of the part in script, it ends in Keyerror.

Is there any way to include the datum references, edge references in a code by our own.

from part import *
from sketch import *

mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=200.0)
mdb.models['Model-1'].sketches['__profile__'].CircleByCenterPerimeter(center=(
    0.0, 0.0), point1=(1.0, 0.0))
mdb.models['Model-1'].Part(dimensionality=THREE_D, name='Part-1', type=
    DEFORMABLE_BODY)
mdb.models['Model-1'].parts['Part-1'].BaseSolidExtrude(depth=10.0, sketch=
    mdb.models['Model-1'].sketches['__profile__'])
del mdb.models['Model-1'].sketches['__profile__']
mdb.models['Model-1'].parts['Part-1'].DatumPlaneByPrincipalPlane(offset=-5.0, 
    principalPlane=YZPLANE)
mdb.models['Model-1'].parts['Part-1'].DatumAxisByPrincipalAxis(principalAxis=
    YAXIS)

mdb.models['Model-1'].ConstrainedSketch(gridSpacing=0.95, name='__profile__', 
    sheetSize=38.2, transform=
    mdb.models['Model-1'].parts['Part-1'].MakeSketchTransform(
    sketchPlane=mdb.models['Model-1'].parts['Part-1'].datums[2], 
    sketchPlaneSide=SIDE1, 
    sketchUpEdge=mdb.models['Model-1'].parts['Part-1'].datums[3], 
    sketchOrientation=RIGHT, origin=(-5.0, 0.0, 0.0)))
mdb.models['Model-1'].parts['Part-1'].projectReferencesOntoSketch(filter=
    COPLANAR_EDGES, sketch=mdb.models['Model-1'].sketches['__profile__'])
mdb.models['Model-1'].sketches['__profile__'].CircleByCenterPerimeter(center=(
    0.0, 0.0), point1=(2.0, 0.0))
mdb.models['Model-1'].sketches['__profile__'].move(objectList=(
    mdb.models['Model-1'].sketches['__profile__'].geometry[3], ), vector=(0.0, 
    5.0))
mdb.models['Model-1'].parts['Part-1'].SolidExtrude(depth=2.0, 
    flipExtrudeDirection=ON, sketch=
    mdb.models['Model-1'].sketches['__profile__'], sketchOrientation=RIGHT, 
    sketchPlane=mdb.models['Model-1'].parts['Part-1'].datums[2], sketchUpEdge=
    mdb.models['Model-1'].parts['Part-1'].datums[3])

sriram
  • 1

2 Answers2

0

You can simply save the datum plane into a variable and use that variable wherever you want.
For ex.

dplaneYZ5 = mdb.models['Model-1'].parts['Part-1'].DatumPlaneByPrincipalPlane(offset=-5.0, 
    principalPlane=YZPLANE)

mdb.models['Model-1'].parts['Part-1'].SolidExtrude(..., 
    sketchPlane=dplaneYZ5 , ...)

I have NOT checked this one. So, please provide your feedback.

Satish Thorat
  • 584
  • 1
  • 5
  • 13
  • Satish Thorat, tried ur suggestion, Resulted in an error. Display message: Invalid sketch plane – sriram May 25 '23 at 11:00
0

If you've given a particular name to your datum plane, axis, whatever feature, it can be referenced in

mdb.models.parts.features

where it has an id attribute (example:

mdb.models['Model-1'].parts['Part-1'].features['Datum plane-1'].id)

Saving this into a variable just before you attempt to call it with datums would be a way to make sure you're calling the right plane. This is also present using Satish's method.
You can save dplaneYZ5.id into a variable, which you could call in datums[]. However, their method should work, as the variable will target that specific plane regardless of what other planes get created.

What, specifically are you trying to change parametrically?

moken
  • 3,227
  • 8
  • 13
  • 23