狮猿社CATIA

CATIA VBA 获取当前激活节点

2020-03-26  本文已影响0人  锦囊喵

原文链接

Sub CATMain()

    Dim doc As PartDocument
    Set doc = GetBluePosionPartDoc()
    
    Dim msg As String
    If doc Is Nothing Then
        msg = "There is no blue position PartDocument."
    Else
        msg = "The blue position PartDocument is " & doc.Name & " ."
    End If
    
    MsgBox msg

End Sub

Private Function GetBluePosionPartDoc() As PartDocument
    
    Set GetBluePosionPartDoc = Nothing
    
    Dim sel As selection
    Set sel = CATIA.ActiveDocument.selection
    
    CATIA.HSOSynchronized = False
    
    With sel
        .Clear
        .Search "CATPrtSearch.Plane,in"
        
        If .Count2 < 1 Then GoTo fin
        
        Set GetBluePosionPartDoc = .Item2(1).Value.Parent.Parent
        .Clear
    End With
    
fin:
    CATIA.HSOSynchronized = True
    
End Function 
上一篇 下一篇

猜你喜欢

热点阅读