Catia Macro: Get Parent of drawing view object
Catia Macro: Get Parent of drawing view object
(OP)
I have created a drawing view of an assembly. In that view, I select an edge or point-Is it possible to get the name of its parent part. Or is it possible to get the point's actual 3D coordinates.





RE: Catia Macro: Get Parent of drawing view object
CODE -->
Sub Draw() Dim oDrawing As DrawingDocument Set oDrawing = CATIA.ActiveDocument Dim oSheets As DrawingSheets Set oSheets = oDrawing.Sheets Dim oSheet As DrawingSheet Set oSheet = oSheets.Item(1) Dim oView As DrawingView Set oView = oSheet.Views.Item(3) oView.Activate Set ProductName = oView.GenerativeBehavior.Document.Parent MsgBox ProductName.Name End Sub______
Alex ,
RE: Catia Macro: Get Parent of drawing view object
CODE --> VBA
Sub Draw() Dim oDrawing As DrawingDocument Set oDrawing = CATIA.ActiveDocument Dim oSheets As DrawingSheets Set oSheets = oDrawing.Sheets Dim oSheet As DrawingSheet Set oSheet = oSheets.Item(1) Dim oView As DrawingView Dim genLinks As Collection For i = 1 To oSheet.Views.Count - 2 'not checking background and main view Set oView = oSheet.Views.Item(i + 2) Set genLinks = ViewGenerativeLinks(oView) If genLinks.Count = 0 Then MsgBox (oView.Name & ": Isolated view") Else For U = 1 To genLinks.Count MsgBox (oView.Name & " link " & U & ": " & genLinks.Item(U).Name) Next U End If Next i End Sub Function ViewGenerativeLinks(oDrawingView As DrawingView) As Collection Dim result As New Collection On Error Resume Next Set oLink = oDrawingView.GenerativeLinks.FirstLink If Err.Number = 0 Then result.Add oLink End If While Err.Number = 0 Set oLink = oDrawingView.GenerativeLinks.NextLink If Err.Number = 0 Then result.Add oLink End If Wend If result Is Not Empty Then Set ViewGenerativeLinks = result Else: Set ViewGenerativeLinks = Empty End If End Functionindocti discant et ament meminisse periti
RE: Catia Macro: Get Parent of drawing view object
Please correct me if i am wrong.
______
Alex ,
RE: Catia Macro: Get Parent of drawing view object
Yes, I was looking for "genItem", so that I can get the parent of the "genItem", which I feel, is not available in VBA library.