如何在 vba 中更新 CATIA 部分?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26536610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 04:58:14  来源:igfitidea点击:

How to update CATIA part in vba?

vbacatia

提问by user3714887

I am trying to edit the part dimension in CATIA by changing the dimension values in the design table in the excel file. Everytime when i change the values i should manually update the part model. I want to update it automatically through VBA code and save it.

我正在尝试通过更改 excel 文件中设计表中的尺寸值来编辑 CATIA 中的零件尺寸。每次更改值时,我都应该手动更新零件模型。我想通过 VBA 代码自动更新它并保存它。

I tried

我试过

Sub CATMain()
CATIA.DisplayFileAlerts = False
Dim part As PartDocument
Set part = CATIA.ActiveDocument
part.Update
part.SaveAs "D:\E\CSE\.....\Part2.CATPart"
End Sub

and it is not working. How can we update and save it??

它不工作。我们如何更新和保存它?

回答by Anho

You called ".Update" on the Document object, not the Part-object! Answer is:

您在 Document 对象上调用了“.Update”,而不是 Part-object!答案是:

Dim part As PartDocument
Set partDoc = CATIA.ActiveDocument
partDoc.Part.Update

回答by GisMofx

Your Code is correct and it should be working. Do you get any errors?

您的代码是正确的,应该可以正常工作。你有任何错误吗?

If you simply want an automatic update try to change your settings ...

如果您只是想要自动更新,请尝试更改您的设置...

Goto Tools->Options Then in the options dialog, goto Infrastructure Tree Node, and expand that and goto Part Infrastructure. Now on the right pane in the General Tab, Make sure you select Automatic for the Updates.

转到工具->选项然后在选项对话框中,转到基础结构树节点,然后展开它并转到零件基础结构。现在在常规选项卡的右窗格中,确保为更新选择自动。

If this doesn't work you could try to the Part.UpdateObject objectToUpdate method to update the individual feature(s) that need to be updated.

如果这不起作用,您可以尝试使用 Part.UpdateObject objectToUpdate 方法来更新需要更新的单个功能。