简体   繁体   English

canvasObjects; 找到PartInstance,期望在Abaqus / CAE中有元组

[英]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.

相关问题 来自Abaqus / CAE的Python多处理 - Python multiprocessing from Abaqus/CAE 无法将 Abaqus PDE 连接到 Abaqus/CAE - Can't connect Abaqus PDE to Abaqus/CAE 如何在abaqus / cae和abaqus / viewer模式下使用abaqus python脚本查询零件的体积信息? - How do i query the parts' volume information with abaqus python script in abaqus/cae and abaqus/viewer mode? 从命令行界面运行abaqus cae命令时出错 - Error in Running abaqus cae command from command line interface 是否可以使用脚本从 Abaqus CAE 中的材料库中导入材料? - Is it possible to import material from material library in Abaqus CAE using scripts? 如何在没有图形用户界面和数据库模型的情况下使用 abaqus cae? - How can I use abaqus cae without graphical user interface and with a database model? 是否可以在Abaqus / CAE中使用用户元素定义网格并使用Python指定其属性,而无需编辑输入文件? - Is it possible to define a mesh with User-Elements and specify their properties with Python in Abaqus/CAE without editing the input file? 如何引用Abaqus Python脚本中的findAt列表/元组 - How to referer to findAt list/tuple in abaqus python script 将列表传递给期望元组长度相同的函数 - passing list to function expecting tuple of same length Python,一种测试集合/列表/元组,期望字符串的优雅方法 - Python, elegant way to test for a set/list/tuple, expecting strings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM