Message 1 of 6
Also counting reference parts, which it should not.!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
I have this great code i got from this thread..:
What it does, is that it counts the total of occurences throughout an assy. Both Parts and sub assys.
Unfortunately i just discovered that it also counts parts and assy's which are set to Reference in BOM, which is a big problem, as we use this from time to time, for our modular configurations.
The code i use now is slightly diffrent as i have added some other functions, but they shouldn't have anything to do with the problem im discribing above.
Dim openDoc As Document Dim docFile As Document Dim assemblyDoc As AssemblyDocument Dim assemblyDef As AssemblyComponentDefinition Dim partQty As ComponentOccurrencesEnumerator Dim FNamePos As Long Dim docFName As String Dim Ordre As String ThisApplication.StatusBarText = "Jeg arbejder... rolig nu.!" openDoc = ThisDoc.Document Ordre = iProperties.Value("Project", "Project") Ordre = InputBox("Er " & Ordre & " det rigtige ordre nr? Ellers skriv det rigtige", "Ordre nummer", Ordre) iProperties.Value("Project", "Project") = Ordre If openDoc.DocumentType = kAssemblyDocumentObject Then For Each docFile In openDoc.AllReferencedDocuments FNamePos = InStrRev(docFile.FullFileName, "\", -1) docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) - FNamePos) If docFile.IsModifiable = True Then assemblyDoc = openDoc assemblyDef = assemblyDoc.ComponentDefinition partQty = assemblyDef.Occurrences.AllReferencedOccurrences(docFile) Try If partQty.Count <> iProperties.Value(docFName, "Custom", "PCS") Then iProperties.Value(docFName, "Custom", "PCS") = partQty.Count End If Catch iProperties.Value(docFName, "Custom", "PCS") = partQty.Count End Try Try If Ordre <> iProperties.Value(docFName, "Project", "Project") Then iProperties.Value(docFName, "Project", "Project") = Ordre End If Catch iProperties.Value(docFName, "Project", "Project") = Ordre End Try End If Next ThisApplication.StatusBarText = "Ready" Else MessageBox.Show("Du kan KUN køre denne regel i en Assembly", "Forkert Filtype",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) End If
Hope someone knows how to make this rule not count the reference occurences..!
/LSA