Model states
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Running rule for total qty in assembly is working just perfect but is not adding total qty for model states . Can this rule be modified? Thank you
Sub Main On Error Resume Next Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document Dim oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") If iProperties.Value("Custom", "TotalUnits") = 0 Then iProperties.Value("Custom", "TotalUnits") = 1 End If Dim Total_Units = iProperties.Value("Custom", "TotalUnits") '**** FOR TESTING PURPOSES - place a ' in front of the next line to skip it ' MessageBox.Show("TotalUnits = " & Total_Units, "iLogic") If openDoc.DocumentType = 12291 Then For Each docFile In openDoc.AllReferencedDocuments Dim propertyName As String = "TTL" Dim propertyValue As Integer = 1 customPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") Dim FNamePos As Long Dim docFName As String FNamePos = InStrRev(docFile.FullFileName, "\", -1) docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) -FNamePos) If docFile.IsModifiable = True Then Dim assemblyDoc As AssemblyDocument Dim assemblyDef As AssemblyComponentDefinition Dim partQty As ComponentOccurrencesEnumerator assemblyDoc = openDoc assemblyDef = assemblyDoc.ComponentDefinition partQty = assemblyDef.Occurrences.AllReferencedOccurrences(docFile) If IsNumeric(partQty.Count) = True Then iProperties.Value(docFName, "Custom", "TTL") = partQty.Count * Total_Units End If End If Next Else MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If End Sub