CATIA VBA:在新窗口打开子装配教程

Sub CATMain()
    Dim InputObjectType(0)
    InputObjectType(0) = "Product"
    Dim oProductDoc
    Set oProductDoc = CATIA.ActiveDocument
    Dim oSelection
    Set oSelection = oProductDoc.Selection
    oSelection.Clear
    Dim aSel
    aSel = oSelection.SelectElement2(InputObjectType, "Select the part to open in a new window", False)
    Dim oProduct
    Set oProduct = oSelection.FindObject("CATIAProduct" )
    Dim prodToOpen as Document
    Set prodToOpen = oProduct.ReferenceProduct.Parent
    prodToOpen.NewWindow 'This is openeing the main product but should open the part?'
    oSelection.Clear
End Sub

Replace all of this....

Dim oProduct
Set oProduct = oSelection.FindObject("CATIAProduct" )

Dim prodToOpen as Document
Set prodToOpen = oProduct.ReferenceProduct.Parent

prodToOpen.NewWindow 'This is openeing the main product but should open the part?

oSelection.Clear

With this....


If aSel = "Normal" Then
CATIA.StartCommand "Open in New Window"
Else
'Take some other action...
End If

As long as an instance is selected, this command will open the part in it's own window. I added a check to be sure the selection was successful before calling because if nothing is selected CATIA just ignores the command plus you might want to take some other action...

http://www.coe.org/p/fo/et/thread=18534

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空