CATIA VBA 获取当前激活节点
2020-03-26 本文已影响0人
锦囊喵
![](https://img.haomeiwen.com/i15269057/073cc08fa3d8def3.png)
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