Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catia Macro: Get Parent of drawing view object

Status
Not open for further replies.

man2007

Aerospace
Joined
Nov 6, 2007
Messages
283
Location
IN
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.
 
Quick code using the view...

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 ,
 
if views are link with sub element of product:

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
    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 Function


Eric N.
indocti discant et ament meminisse periti
 
I've been searching fot this issue

man2007 said:
In that view, I select an edge or point-Is it possible to get the name of its parent part.


Google said:
.Restriction Explanation
Generative geometry object (genItem) is not
exposed by automation API, that's why it is not
possible to select it.
.
.By-Pass
Generative Geometry is only accessible by CAA
C++ interface

Please correct me if i am wrong.

______

Alex ,
 
Thanks AlexLozoya and itsmyjob for your replies.

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top