我是论坛的新手。我不是专家程序员,但我需要在python中编写脚本,以便在没有GUI的情况下使用Abaqus运行有限元仿真。模拟运行正常,但是当我尝试生成包含结果的文本文件时,我得到了以下错误提示
文件“C:/ ... my_scrypt.py,第208行,在INTEGRATION_POINT中),)) 没有活跃的实体。尚未生成任何报告
这是脚本:
(197) from odbAccess import *
(198) from abaqusConstants import *
(199) from odbMaterial import *
(200) from odbSection import *
(201)
(202) o1 = session.openOdb(name='C:/Temp/Job-1.odb')
(203) odb = session.odbs['C:/Temp/Job-1.odb'].steps['apply_load']
(204) session.writeFieldReport(fileName='C:/Temp/abaqus.rpt', append=ON,
(205) sortItem='Element Label', odb=odb, step=0, frame=1,
(206) outputPosition=INTEGRATION_POINT, variable=(('PEMAG',
(207) INTEGRATION_POINT), ('PRESSONLY', INTEGRATION_POINT), ('S',
(208) INTEGRATION_POINT), ))
感谢您的帮助
答案 0 :(得分:0)
非常感谢帮助人员。这是工作代码:
from odbAccess import *
from abaqusConstants import *
from odbMaterial import *
from odbSection import *
o1 = session.openOdb(name='C:/Temp/Job-1.odb')
session.viewports['Viewport: 1'].setValues(displayedObject=o1)
session.viewports['Viewport: 1'].odbDisplay.setFrame(step=0, frame=1)
odb = session.odbs['C:/Temp/Job-1.odb']
session.fieldReportOptions.setValues(columnLayout=SEPARATE_TABLES)
session.writeFieldReport(fileName='C:/Temp/abaqus.rpt', append=OFF,
sortItem='Element Label', odb=odb, step=0, frame=1,
outputPosition=INTEGRATION_POINT, variable=(('PEMAG',
INTEGRATION_POINT), ('PRESSONLY', INTEGRATION_POINT), ('S',
INTEGRATION_POINT), ))
答案 1 :(得分:0)
当我开始使用Python编程时,这也是我的第一行代码,效果很好。但是,现在我正在扩展代码,因此开始出现与您所描述的错误相同的错误:“没有活动实体。未生成报告”。
在您的情况下,您正在使用一个称为“视口:1”的现有视口,但是,在创建新视口时,必须将该视口设为当前视口。 这是我用来创建myViewport的以下代码:
myViewport = session.Viewport(name=ViewportName, origin=(0, -100),width=250, height=150)
myViewport.odbDisplay.commonOptions.setValues(visibleEdges=FREE,deformationScaling=UNIFORM,uniformScaleFactor=(1))
# Open the output database and associate it with the viewport.
# Then set the plot state to CONTOURS_ON_DEF
try: myOdb = visualization.openOdb(path=odbNames)
except (AbaqusException), value: print ('Error:', value)
myViewport.setValues(displayedObject=myOdb)
myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
myViewport.viewportAnnotationOptions.setValues(triad=OFF,title=OFF,state=OFF,compass=OFF, legendDecimalPlaces=2,legendNumberFormat=FIXED)
myViewport.odbDisplay.basicOptions.setValues(coordSystemDisplay=OFF, renderBeamProfiles=ON)
myViewport.view.rotate(xAngle=90,yAngle=90,zAngle=0)
myViewport.view.rotate(xAngle=90,yAngle=90,zAngle=0)
myViewport.view.rotate(xAngle=0, yAngle=0, zAngle=180)
# myViewport.view.rotate(mode=TOTAL)
myViewport.view.pan(xFraction=0.1) # yFraction for vertical panning
myViewport.view.setValues(projection=PARALLEL)
myViewport.makeCurrent() #This makes the viewport current