[英]canvasObjects; found PartInstance, expecting tuple in Abaqus/CAE
I'm developening an Abaqus/CAE plug-in, in this plug-in i'm using the gui toolkit, and i have a button that uses the PickStep, on click the button i can select a PartInstance in the viewport. 我正在开发一个Abaqus / CAE插件,在该插件中,我使用的是gui工具包,并且我有一个使用PickStep的按钮,单击该按钮后,我可以在视口中选择PartInstance。
Then i want to export the selected PartInstance to an .obj file but when i try it, abaqus displays an error. 然后,我想将选定的PartInstance导出到.obj文件,但是当我尝试使用它时,abaqus显示错误。
This is an example of my PICK BUTTON: 这是我的选择按钮的一个示例:
# 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)
I save the value in an ObjectKeyword: 我将值保存在ObjectKeyword中:
self.uper = AFXObjectKeyword(self.cmd, 'uper', True, pickedDefault)
This is how i export the PartInstance to .obj: 这就是我将PartInstance导出到.obj的方式:
print 'Uper - ' + uper[0].name
f.write('Uper - '+uper[0].name+'\n')
session.writeOBJFile(fileName='C:/temp/Uper.obj', canvasObjects=(uper[0]))
That displays and error, and i also tried this: 显示和错误,并且我也尝试了这个:
print 'Fixed - ' + fixed[0].name
f.write(fixed[0].name+'\n')
fixedobj = open('Fixed.obj', 'w')
pickle.dump(fixed[0], fixedobj)
fixedobj.close()
But that does not work either. 但这也不起作用。
I get this error: 我收到此错误:
canvasObjects;found PartInstance, expecting tuple canvasObjects;找到PartInstance,期望元组
This answer will help you. 这个答案将为您提供帮助。 On your call to
session.writeOBJFile
you are trying to create a one element tuple for the canvasObjects
argument. 在对
session.writeOBJFile
的调用中,您尝试为canvasObjects
参数创建一个元素元组。 Simply wrapping the item in parentheses won't achieve that. 仅将项目包装在括号中将无法实现。 You need to add a comma to make it a tuple:
您需要添加一个逗号使其成为一个元组:
session.writeOBJFile(fileName='C:/temp/Uper.obj', canvasObjects=(uper[0],))
The Abaqus documentation says this about canvasObjects
: Abaqus文档说了有关
canvasObjects
:
canvasObjects
canvasObjects
A sequence of canvas objects to export.
要导出的画布对象序列。
I'm not sure if PartInstance
is considered a canvas object or not, but you may still have problems even after correcting the argument to be a tuple. 我不确定
PartInstance
是否被视为画布对象,但是即使将参数更正为元组,您仍然可能会遇到问题。 If so, make sure the items of the tuple are proper canvas objects. 如果是这样,请确保元组的项目是正确的画布对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.