analyse links between Files with oStiDBItem.GetChildren

Xavier Klein

analyse links between Files with oStiDBItem.GetChildren

Hello,

A very sensitive Topic in CATIA V5  are links between Part Product Drawing  (using catia without Enovia/Smarteam/Temcenter .. )

In Graphic User interface , you have Edit / Links which  display this information,

For a long time , I have try to be able to retreive this information with a batch running a Catia Macro

-

First solution :   make a loop on each subproduct ,

For i = 1 To ProductFather.Products.Count

   Set ProductSon = ProductFather.Products.Item(i)

   SonPathName = ProductSon.GetMasterShapeRepresentationPathName

problem with this solution :

- take a long time to load the Assembly ,

- if a file is missing , it is not possible to analyse it

- there are many different specific and complicate case to handle

- for other catia Filetype , CATPart CATDrawing CATAnalysis , need to make an other macro

 

Second Solution : use specific API from Smarteam  (do not need to setup Smarteam)

the source code have been found on COE Forum , thanks a lot to people who share it  !!!!!

Set oStiDBChildren = oStiDBItem.GetChildren
For i = 1 To oStiDBChildren.Count
    Set oStiDBItem2 = oStiDBChildren.Item(i)
    SonName = oStiDBItem2.GetDocumentFullPath

Very Big Benefit with this Solution :

- Product can be loaded Without option "Load Referenced Documents"   => very faster

- The code is quiet more simple , and you can analyse all CATIA FileType : CATPart , CATProduct , CATDrawing , CATAnalysis ......

 

I have only get on trouble to analyse SubProduct , see sample

Product1

- Part1

- Product2

- Model V4 1

- Component1 ( internal Product )

-- Part 2

 

I was not able to retreive  Model V4 1 / Part 2 , with Code found on COE Forum , SonName = Product1.name

BUT , I was VERY VERY satisfied to find a solution , So I wanted to share it

you have to make a recursive Analyse , see sample below :

 

Sub AnalyseLink ()

    Set CATIA = GetObject(, "CATIA.Application") 
    Dim oStiEngine ' As StiEngine
    Set oStiEngine = CATIA.GetItem("CAIEngine")
    Dim oStiDBItem ' As StiDBItem
    Set oStiDBItem = oStiEngine.GetStiDBItemFromAnyObject(CATIA.ActiveDocument)

    Debug.Print CATIA.ActiveDocument.FullName
    call AnalyseSubProduct(oStiDBItem, CATIA.ActiveDocument.FullName , "")

End Sub

Sub AnalyseSubProduct(oStiDBItem, FatherName As String, TabStrFather As String)

    Dim i As Integer
    Dim oStiDBChildren
    Dim oStiDBItem2 ' As StiDBItem  -- Smarteam is not SetUp , API recognize , so use AnyObject Type
    Dim SonName As String
    Dim TabStrChildren As String
   
    Set oStiDBChildren = oStiDBItem.GetChildren
    For i = 1 To oStiDBChildren.Count
        Set oStiDBItem2 = oStiDBChildren.Item(i)
        SonName = oStiDBItem2.GetDocumentFullPath
        
        TabStrChildren = TabStrFather & "-"
        LinkType = CStr(oStiDBChildren.LinkType(i))
        If SonName = FatherName Then
            ' in Case of Product with Subcompoent   Or Product with CATIA V4 model
            ' recursive Analyse to SubProduct
            Call AnalyseSubProduct(oStiDBItem2, FatherName, TabStrChildren)
        Else
            ' Add information in Database about link between Files
            Debug.Print TabStrFather & SonName & "  " & i & "" & oStiDBChildren.Count & "  " & LinkType
        End If
    Next i

End Sub

 

with this code , I have been able to analyse 500 000 catia files and identify all links of any type

Little Cthulhu

RE: analyse links between Files with oStiDBItem.GetChildren
(in response to Xavier Klein)

Hi.

 

Thanks for sharing! Very nice to see people come here with valuable pieces of advice. 

As for now we use WinAPI-based solution that retrieves exact contents of Edit-Links window. Main advantage this approach gives us is that it can be used for features as well.

But at this moment I'm trying to develop alternative CAA-RADE solution and expose it to VBA. Seems like links have very different nature and must be obtained totally differently. If anyone has any experience in this, I'd like to ask for an assistance.

 

Edited By:
Little Cthulhu[Sikorsky Aircraft] @ Sep 19, 2014 - 11:48 PM (Europe/Moscow)
Little Cthulhu[Sikorsky Aircraft] @ Sep 19, 2014 - 11:53 PM (Europe/Moscow)

Jon Houghton

RE: analyse links between Files with oStiDBItem.GetChildren
(in response to Little Cthulhu)

Thanks for the code Xavier. I didn't know that it was possible to access StiEngine without Smarteam.

Little Cthulu - I don't have much advice, but I can tell you that its definitely possible as I have seen it exposed via COM. It appears that different element link types are accessed through different channels.

Edited By:
Jon H[Pacifica-Engineering Inc] @ Sep 19, 2014 - 02:56 PM (America/Pacific)

Little Cthulhu

RE: analyse links between Files with oStiDBItem.GetChildren
(in response to Jon Houghton)

Thanks, Jon.

 

May I ask where have you seen it?  I'd like to know who may also be interested in such implementation.

Fernando Petre

RE: analyse links between Files with oStiDBItem.GetChildren
(in response to Little Cthulhu)

Hi,

Hope it helps.

http://www.grozeaion.com/catia/v5-programming

Is gvi70000 website

 

 

Best regards

Fernando

https://picasaweb.google.com/102257836106335725208

https://picasaweb.google.com/103462806772634246699/