Search code examples
vbacatia

How to know which Catia Body is publication if names of all the bodies are same


I have been looking for an answer to this question for 5 days now, The question is: If I have many bodies with the same name and one of them is released as a publication. Now, how can I know which body is released as a publication. Is there a way to compare a publication with each body (please remember that the names of bodies are the same). And can I access the body with the publication object? please respond if you have any idea about it. Thanks

The image represents the above question.


Solution

  • Therefor you can use the selection as a workaround: Get the reference of the publication and select this reference

    Sub CATMain()
    
    Set oPartDocument = Catia.ActiveDocument
    Set oPublication = oPartDocument.Product.Publications.Item(1)
    Set oSel = oPartDocument.Selection
    
    Set oReference = oPublication.Valuation
    
    oSel.Clear
    oSel.Add oReference
    
    Set oSelObject = oSel.Item2(1).Value
    
    MsgBox oSelObject.Name
    
    End Sub