I am having issues with one of my external rules and I can't figure out why. The rule is working perfectly in a part document. This part becomes an asset for the Factory Design Suite. When I place this asset then into my layout I get the following error:
I think it has something to do with the ComponentDefinition difference between a part and assembly, but I don't know how to solve this.
The rule is external because every asset in my library is using the same rule.
This is the code:
Dim oDoc As Inventor.Document = ThisApplication.ActiveDocument Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition Dim InvApp As Application = ThisApplication Dim oAnnotation3D As ModelAnnotation i = 1 For Each ModelAnnotation In oCompDef.ModelAnnotations oAnnotation3D = oCompDef.ModelAnnotations.Item(i) If SharedVariable("State") = "Dimensions" And InStr(oAnnotation3D.Name, "Dimension") Then If oAnnotation3D.HealthStatus.value__ <> 11778 Then oAnnotation3D.Visible = False Else oAnnotation3D.Visible = True End If Else If InStr(oAnnotation3D.Name, "Dimension") Then oAnnotation3D.Visible = False End If i = i + 1 Next
A part that uses the rule and is working fine on its own is also attached.
Solved! Go to Solution.
Solved by gert-leonvanlier. Go to Solution.
I found a solution:
Sub Main() Dim topDoc As Document = ThisDoc.Document ProcessDoc(topDoc) For Each doc As Document In topDoc.AllReferencedDocuments ProcessDoc(doc) Next End Sub Sub ProcessDoc(doc As Document) If (doc.DocumentType = DocumentTypeEnum.kPartDocumentObject) Then Dim partDoc As PartDocument = doc ProcessPart(partDoc) End If End Sub Sub ProcessPart(partDoc As PartDocument) Dim oCompDef As PartComponentDefinition = partDoc.ComponentDefinition Dim InvApp As Application = ThisApplication Dim oAnnotation3D As ModelAnnotation i = 1 For Each ModelAnnotation In oCompDef.ModelAnnotations oAnnotation3D = oCompDef.ModelAnnotations.Item(i) If SharedVariable("State") = "Dimensions" And InStr(oAnnotation3D.Name, "Dimension") Then If oAnnotation3D.HealthStatus.value__ <> 11778 Then oAnnotation3D.Visible = False Else oAnnotation3D.Visible = True End If Else If InStr(oAnnotation3D.Name, "Dimension") Then oAnnotation3D.Visible = False End If i = i + 1 Next End Sub
Can't find what you're looking for? Ask the community or share your knowledge.