catia能用python开发吗_使用Python在CATIA中创建新产品

I am automating the creation of a new product with a Python script and have run into a problem with the interactive events getting stuck at the "Part Number" dialog. This does not occur when creating a new part, just a new product. Here is the applicable portion of the script (CATIA is open):

import win32com.client.dynamic

CATIA = win32com.client.Dispatch("CATIA.Application")

catDocs = CATIA.Documents

# Create a new product

newProductDoc = catDocs.Add("Product")

# "Part Number" window appears, requesting a name for the product

# Interactive processes will not proceed

newProduct = newProductDoc.Product

newProductSet = newProduct.Products

newPart = newProductSet.AddNewComponent("Part", "dummyPart")

...

The problem is that I am developing a small tool for others to use and it is not very useful if it hangs up.

Clicking on "Cancel" gets rid of the dialog box, but no interactive actions occur afterwards. Clicking on "Ok" resolves the problem, but it would be preferable for the script to be able to prepare the product as a final result without interaction in order to restrict user error and improve ease of use.

I know that I can create a product and manipulate it (i.e. add parts, add new products, etc.), then successfully save it. So the processes are being executed, they just aren't being displayed anymore. I just can't seem to find a way to get past the "Part Number" dialog box. I even tried naming it programmatically, which worked but didn't kill the dialog box.

Opening an existing product works very well, and any scripting processes can continue without problems. However, programmatically creating the product, saving, and closing causes CATIA to lock up... so the option of saving and re-opening as an existing product is out the window.

I also referenced the v5Automation.chm, but I couldn't find a way of interacting with dialog boxes.

I also tried .Update() on the new product and it's parts. Some other assurances were CATIA.Visible = True and CATIA.RefreshDisplay = True.

Disclaimer: I know that VBA can be used and does not pose this problem. I am looking for a solution to this problem using Python (2 or 3, doesn't matter).

解决方案

I was trying to replicate your issue, but I dind't encounter it. Products just created fine using incremental default names.

Then I thought it was something related to Settings since the dialog is simlar to the one that optionally pops up when addin a new part.

I discovered that I had the option Infrastructure > Product Infrastructure > Product structure > Part Number: Manual input unchecked.

I don't know how this was related to using VBA or not, but checking it created the issue and unchecking it removed the issue, while still sending the same command from Python.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值