Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Thanks for your code, you mean by "Part1" is the name of the occurrence in the design tree or the name of the file in the project directory? 

I am trying to refer to specific ( part, occurrence) in the assembly automatically not by selecting its item number from the Watch window but rather to search for that occurrence for me  ( see my new code)

Sub ADDHingeDimension()

' refer to the file
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

' refer to the sheet
Dim oSheet As Sheet
Set oSheet = oDrawDoc.Sheets.Item(1)

'refer to the View
Dim oView As DrawingView
Set oView = oSheet.DrawingViews.Item(1)

'refer to refrenced Assembly
Dim oAssembly As AssemblyDocument
Set oAssembly = oView.ReferencedDocumentDescriptor.ReferencedDocument

'refer the the Model in the Assembly
Dim i As Integer
For i = 1 To oAssembly.AllReferencedDocuments.Count
Dim oModelDoc As Document
Set oModelDoc = oAssembly.ReferencedDocuments.Item(i)

'refer to the Edge on the Model
If oModelDoc.DisplayName = "Hopper_InspectionDoor_cover.ipt" Then
Set oModelDoc = oAssembly.ReferencedDocuments.Item(i)
Dim Edge2 As Edge
Set Edge2 = oModelDoc.AttributeManager.FindObjects("*", "*", "Door_Left").Item(1)
Exit For
ElseIf oModelDoc.DisplayName = "Hopper_InspectionDoor_Plate.ipt" Then
Set oModelDoc = oAssembly.ReferencedDocuments.Item(i)
Dim Edge1 As Edge
Set Edge1 = oModelDoc.AttributeManager.FindObjects("*", "*", "Plate_Type1_Left").Item(1)
 
End If
Next

' refer to occurrance in the assembly
Dim j As Integer
For j = 1 To oAssembly.ComponentDefinition.Occurrences.Count
Dim oOcc As ComponentOccurrence
Dim oOcc1 As ComponentOccurrence
Dim oOcc2 As ComponentOccurrence
Set oOcc = oAssembly.ComponentDefinition.Occurrences.Item(j)

If oOcc.Name = "Hopper_InspectionDoor_Door:1" Then
Set oOcc2 = oAssembly.ComponentDefinition.Occurrences.Item(j)

ElseIf oOcc.Name = "Hopper_InspectionDoor_Plate:2" Then
Set oOcc1 = oAssembly.ComponentDefinition.Occurrences.Item(j)

Exit For
End If
Next

' promot edge to proxy
Dim oproxy1 As EdgeProxy
  Call oOcc1.CreateGeometryProxy(Edge1, oproxy1)
Dim oproxy2 As EdgeProxy
  Call oOcc2.CreateGeometryProxy(Edge2, oproxy2)
 
 ' promot proxy to Drawing curve
 Dim oCurve1 As DrawingCurve
 Set oCurve1 = oView.DrawingCurves(oproxy1).Item(1)
 
 Dim oCurve2 As DrawingCurve
 Set oCurve2 = oView.DrawingCurves(oproxy2).Item(1)

of course, my code is incomplete and the last line introduces error to me I do not why, in the Watch Window,  the Variable called "oView.DrawingCurves(oproxy2)" contains no items  see below 

Capture1.PNG

  what I really like to do is to place a dimension between two different parts in the assembly ( inspection door)

see this view below 

Capture.PNG