美文网首页狮猿社CATIA
CATIA VBA:在新窗口打开子装配

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

作者: 锦囊喵 | 来源:发表于2020-04-06 11:11 被阅读0次
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

相关文章

网友评论

    本文标题:CATIA VBA:在新窗口打开子装配

    本文链接:https://www.haomeiwen.com/subject/rhmvphtx.html