Welcome ! hope this blog make you unconstrained!
The core part of script is marked as red and comments are in blue.
# commands to get library file stored in abaqus
from abaqus import *# commands to get library file stored in abaqus
from abaqusConstants import *
backwardCompatibility.setValues(includeDeprecated=True,
reportDeprecated=False)
import sketch
import part
# creating variables by calling the constructors
myModel = mdb.Model(name='Model A')
mySketch = myModel.ConstrainedSketch(name='Sketch A',
sheetSize=200.0)
lines = open('redmodel.txt', 'r').readlines()
#give your text file here. readlines() function reads all lines #from the given .txt file
pointList = [] #Creating empty array
for line in lines:
#reading line by line and performing action
pointList.append( eval( '(%s)' % line.strip() ) )
#strip() func removes all the white spaces from a line. #
eval function which evaluates a string as though it were #an expression and returns a result and append adds each coordinate
# as last element of array
for i in range(len(pointList)-1):
mySketch.Line(point1=pointList[i],
point2=pointList[i+1])
# Above for loop will help in connecting the coordinates in the
# sequence
myPart = myModel.Part(name='Part A', dimensionality=THREE_D,
type=DEFORMABLE_BODY)
myPart.BaseSolidExtrude(sketch=mySketch, depth=20.0)
myViewport = session.Viewport(name='Viewport for Model A',
origin=(10, 10), width=150, height=100)
myViewport.setValues(displayedObject=myPart)
Note: make sure that given .txt file is available in your set working directory.