我正在开发一个Abaqus/CAE插件,在这个插件中,我使用gui工具包,我有一个使用PickStep的按钮,点击我可以在视口中选择一个PartInstance的按钮。
然后,我想将所选的PartInstance导出到.obj文件中,但是当我尝试它时,abaqus会显示一个错误。
这是我的选择按钮的一个例子:
# PICK BUTTON 1
pickHf = FXHorizontalFrame(p=col2, opts=0, x=0, y=0, w=0, h=0, pl=0, pr=0, pt=0, pb=0, hs=DEFAULT_SPACING,
vs=DEFAULT_SPACING)
# Note: Set the selector to indicate that this widget should not be
# colored differently from its parent when the 'Color layout managers'
# button is checked in the RSG Dialog Builder dialog.
pickHf.setSelector(99)
label1 = FXLabel(p=pickHf, text='' + ' (None)', ic=None, opts=LAYOUT_CENTER_Y | JUSTIFY_LEFT)
pickHandler1 = DBPickHandler(form, form.uper, 'Select a 3D, discrete and dependent meshed instance', INSTANCES,
1, label1)
icon = afxGetIcon('select', AFX_ICON_SMALL)
FXButton(p=pickHf, text='\tPick Items in Viewport', ic=icon, tgt=pickHandler1, sel=AFXMode.ID_ACTIVATE,
opts=BUTTON_NORMAL | LAYOUT_CENTER_Y, x=0, y=0, w=0, h=0, pl=2, pr=2, pt=1, pb=1)我将值保存在一个ObjectKeyword中:
self.uper = AFXObjectKeyword(self.cmd, 'uper', True, pickedDefault)我是这样将PartInstance导出到.obj的:
print 'Uper - ' + uper[0].name
f.write('Uper - '+uper[0].name+'\n')
session.writeOBJFile(fileName='C:/temp/Uper.obj', canvasObjects=(uper[0]))显示和错误,我也尝试过这样做:
print 'Fixed - ' + fixed[0].name
f.write(fixed[0].name+'\n')
fixedobj = open('Fixed.obj', 'w')
pickle.dump(fixed[0], fixedobj)
fixedobj.close()但这也不起作用。
我知道这个错误:
canvasObjects;找到PartInstance,期待元组
发布于 2019-05-07 13:11:01
This answer会帮你的。在调用session.writeOBJFile时,您试图为canvasObjects参数创建一个元组。简单地将项目包装在圆括号中并不能实现这一点。您需要添加逗号才能使其成为元组:
session.writeOBJFile(fileName='C:/temp/Uper.obj', canvasObjects=(uper[0],))Abaqus的文档说明了关于canvasObjects的情况
canvasObjects 要导出的一系列画布对象。
我不确定PartInstance是否被认为是画布对象,但即使将参数修正为元组,您也可能会遇到问题。如果是这样,请确保元组的项目是适当的画布对象。
https://stackoverflow.com/questions/56000791
复制相似问题