Inventor rule does not work anymore

Inventor rule does not work anymore

morrenengineering
Contributor Contributor
315 Views
1 Reply
Message 1 of 2

Inventor rule does not work anymore

morrenengineering
Contributor
Contributor

Dear members,

 

I had this rule like under, but it does not work since the last update. Can someone help me

 

This error is given

Error in rule: bevestigingsmaterialen-OFF, in document: C152.iam

Object reference not set to an instance of an object.

 

Dim assemblyDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition

Dim occ As Inventor.ComponentOccurrence
For Each occ In assemblyDef.Occurrences.AllLeafOccurrences
    Dim refDoc As PartDocument = occ.Definition.Document
    
    Dim customPropSet As PropertySet
    customPropSet = refDoc.PropertySets.Item("Inventor User Defined Properties")

	Dim weightProp As Inventor.Property
	weightProp = Nothing
	Try
		weightProp = customPropSet.Item("art")
    Catch ex As Exception
	End Try		
    
    
    weightVal = weightProp.Value
        
        If weightVal = "BEV" Then
            occ.Visible = False
        Else
            occ.Visible = True
        End If

Next

 

 

 

0 Likes
Accepted solutions (1)
316 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor
Accepted solution

i expect that there is an part without a iProperty "art". try this rule and you will know for sure:

Dim assemblyDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition

Dim occ As Inventor.ComponentOccurrence
For Each occ In assemblyDef.Occurrences.AllLeafOccurrences
    Dim refDoc As PartDocument = occ.Definition.Document
    
    Dim customPropSet As PropertySet = refDoc.PropertySets.Item("Inventor User Defined Properties")

	Dim weightProp As Inventor.Property
	weightProp = Nothing
	Try
		weightProp = customPropSet.Item("art")
    Catch ex As Exception
		MsgBox("Could not find iProperty 'art' in part " & refDoc.DisplayName)
	End Try		
    If weightProp Is Nothing Then continue For
    
    weightVal = weightProp.Value
        
    If weightVal = "BEV" Then
        occ.Visible = False
    Else
        occ.Visible = True
    End If
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes