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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the link of a 2D Component Instance from a Drawing Catalog in CATIA VBA?

Med Che

New member
Joined
Oct 21, 2023
Messages
10
Location
TN
Hello everyone,

I'm trying to retrieve the link (path or reference) of a 2D Component Instance that comes from a 2D catalog in a CATIA Drawing using VBA.

Here's a snippet of my current code:

Sub CATMain()
Dim catia1 As Object
Set catia1 = CATIA.ActiveDocument

Dim myviews As Object
Set myviews = catia1.Sheets.Item(1).views

Dim mycomp As Object
Set mycomp = myviews.Item(3).components
Dim links1 As String
Set links1 = mycomp.Item(1).CompRef.GenerativeBehavior.Document.Reference.FullName
Debug.Print links1


End Sub


However, this line throws an issue because the 2D Component Instance is not linked to a Part or Product, but instead comes directly from a 2D catalog.
Has anyone encountered this situation?

Is there an alternative method to retrieve the source (path or catalog reference) of the 2D Component Instance?

1751712164466.png
 
Code:
Dim comp as DrawingComponent
Set comp = CATIA.ActiveDocument Selection.Item(1).Value

Dim refView as DrawingView
Set refView = comp.CompRef

Dim refSheet as DrawingSheet
Set refSheet = refView.Parent.Parent

Dim refDoc as DrawingDocument
Set refDoc = refSheet.Parent.Parent

Debug.Print refDoc.FullName
 
Thank you for your answer, but there's an issue with the parent command.
 

Part and Inventory Search

Sponsor

Back
Top