Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

StiEngine

Status
Not open for further replies.

romaleee

Mechanical
May 13, 2016
37
Hi.

I am trying to write a script that would find and sort all the external links, in an assembly, into next classes:

1. OK
2. Not synchronized
3. Document not found
4. Document not loaded
5. Reference not found

so I can repair bolded ones. I need this only for external parameters so I'm taking only KWE_REFERENCE-s into consideration. The problem is that I don't know how to access to Link status value or from/to references of link. I manged to extract "Document not found links". Does anyone have an idea how to sort rest of them. Output would be an xls.file with paths of bolded parameters but thats an easy thing to do when and if I solve first problem.

Code:
Sub AnalyseLink()

    Dim oStiEngine  As StiEngine
    Set oStiEngine = CATIA.GetItem("CAIEngine")
    Dim oStiDBItem  As StiDBItem
    Set oStiDBItem = oStiEngine.GetStiDBItemFromAnyObject(CATIA.ActiveDocument)
    Call AnalyseSubProduct(oStiDBItem)

End Sub

Sub AnalyseSubProduct(oStiDBItem)

    Dim i As Integer
    Dim SonName, LinkType As String
    Dim oStiDBChildren As StiDBChildren
    Dim oStiDBItem2  As StiDBItem
    Set oStiDBChildren = oStiDBItem.GetChildren
    Dim odocument As Document
        For i = 1 To oStiDBChildren.Count
        Set oStiDBItem2 = oStiDBChildren.Item(i)
        On Error Resume Next
        Set odocument = oStiDBItem2.GetDocument
        
        If Err.Number = 0 Then
            MsgBox ("Rest of versions")
        Else
            MsgBox ("Document NOT found")
        End If
        Err.Clear
        
        SonName = oStiDBItem2.GetDocumentFullPath
        LinkType = CStr(oStiDBChildren.LinkType(i))
    Next i
End Sub

Ty
 
Replies continue below

Recommended for you

Hello, for the document loaded you may use this as inspiration:

Code:
  Err.Clear
  On Error Resume Next

  '//---------- Get the active document
  Set objGCATIADocument0 = CATIA.ActiveDocument
  If Err.Number <> 0 Then
    MsgBox "You must have a loaded and active document in the session", _
    vbOkOnly + vbCritical, "Erreur au chargement du modèle"
    Exit Sub
  End If
  Err.Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor