Hello CATIA Community,
We try to get the "Link to Reference" properties (the CATIA Part/Product file path) and the Instance name property via CATIA VBA API when this CATIA Part/Product is not loaded in the CATIA (it is a broken link)
When this child CATIA Part/CATIA Product object is loaded we can easily do it in the following way:
Set cad = catia.ActiveDocument
Set childProds = cad.product.Products
Dim childProd As product
Set childProd = childProds.Item(1)
Dim instanceName As String
Dim filePath As String
instanceName = childProd.name
filePath = childProd.ReferenceProduct.Parent.fullName
or with the StiEngine API:
Dim catEngine As StiEngine
Set catEngine = catia.GetItem("CAIEngine")
Dim product As ProductDocument
Set product = GetActiveProductDocument()
Dim rootItem As StiDBItem
Set rootItem = catEngine.GetStiDBItemFromAnyObject(product)
Dim childs As StiDBChildren
Set childs = rootItem.GetChildren
Dim curChild As StiDBItem
Set curChild = childs.Item(1)
Dim filePath As String
filePath = curChild.GetDocumentFullPath()
Dim obj As Object
Set obj = curChild.GetDocument()
Dim refProd As product
Set refProd = obj.product.ReferenceProduct
Dim instanceName As String
Set cad = catia.ActiveDocument
Set childProds = cad.product.Products
Dim childProd As product
For i = 1 To childProds.count
Set childProd = childProds.Item(i)
If (childProd.ReferenceProduct Is refProd) Then
instanceName = childProd.name
Exit For
End If
Next i
But when this child CATIA Part/CATIA Product object is NOT loaded:
- In the first approach the childProd.ReferenceProduct property doesn't work;
- In the second appoach the curChild.GetDocument() method doesn't work.
Could you please help us to find a solution?