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

Hi, this could be a start

 

If the first view reference is an assembly document and if the assembly document references a custom property a message box will appear with value.

 

 

   Sub main
	   Dim CustomProp As String = "CustompropName" 'property to be found change this

        Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
        Dim oSheet As Sheet = oDrawDoc.ActiveSheet
		If oSheet.DrawingViews.Count = 0 Then Exit Sub
        Dim oView As DrawingView = oSheet.DrawingViews.Item(1) 'firts view to be found
		
	

        Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
        If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then

            Dim oCustomprop As Inventor.Property = GetCustomprop(oDoc, CustomProp)
            If oCustomprop IsNot Nothing Then
                Dim oCustompropValue As String = oCustomprop.Value
                MsgBox(oCustompropValue)
            End If
        End If
	End Sub
	
		 Private Function GetCustomprop(AssyDoc As AssemblyDocument, CustomProp As String) As Inventor.Property
        Dim result As Inventor.Property = Nothing
        Try
            ' Get the PropertySets object.
            Dim oPropSets As PropertySets = AssyDoc.PropertySets
            ' Get the design tracking property set.
            Dim oPropSet As Inventor.PropertySet = oPropSets.Item("Inventor User Defined Properties")
            ' Get the part number iProperty.
            Dim oPartNumiProp As Inventor.Property = oPropSet.Item(CustomProp)
            result = oPartNumiProp
        Catch ex As Exception

        End Try
        Return result
    End Function

 

If a response answers your question, please use  ACCEPT SOLUTION  to assist other users later.

Also be generous with Likes!  Thank you and enjoy!