我的主页:
博客园文章链接:
正在学习基于ABAQUS-PYTHON的GUI开发,出于练手的想法,编写了一个简单的插件。
实现功能:
kernel python 代码:
# -*- coding: mbcs -*-
# Do not delete the following import lines
# version 1.0
from abaqus import *
from symbolicConstants import *
from abaqusConstants import *
import __main__
def BeamBuilder(BeamBuilderEnable,ModelName,PartName,MergeType,Meshable,Points,Rods):
# create a model
mdb.Model(name=ModelName,modelType=STANDARD_EXPLICIT)
mymodel=mdb.models[ModelName]
# create a blank part
p=BlankPart(mymodel,PartName)
meshable=SymbolicConstant(name=Meshable.upper())
mergetype=SymbolicConstant(name=MergeType.upper())
nodes=Points
beams=Rods
print('point numbers='+str(len(nodes)))
print('rods numbers='+str(len(beams)))
nodesDict={}
for i in range(len(nodes)):
node_index=nodes[i]
nodesDict[node_index[0]]=node_index[1:4]
lines=[]
for i in range(len(beams)):
line_index=beams[i]
line=(nodesDict[line_index[1]],nodesDict[line_index[2]])
lines.append(line)
p.WirePolyLine(points=tuple(lines), mergeType=mergetype, meshable=meshable)
# create a balnk part object
def BlankPart(Model,PartName):
# return sketch
s = Model.ConstrainedSketch(name='__profile__', sheetSize=200.0)
# view setting
s.setPrimaryObject(option=STANDALONE)
s.ArcByStartEndTangent(point1=(-36.25, 13.75), point2=(-17.5, 7.5), vector=(1.0, 0.0))
# create a part according to the sketch
p = Model.Part(name=PartName, dimensionality=THREE_D, type=DEFORMABLE_BODY)
p = Model.parts[PartName]
p.BaseWire(sketch=s)
s.unsetPrimaryObject()
del Model.sketches['__profile__']
temp=p.features.keys()
del p.features[temp[0]]
return p