狮猿社CATIA

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

2020-04-06  本文已影响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

上一篇 下一篇

猜你喜欢

热点阅读