Hello,
I would like to count all my parts in the main assembly and assign that amount to each part.
Example: Main assembly has: 10 Parts A and 5 Parts B. I would like to run a rule that "sends" that "10" to Part A.ipt and the "5" to Part B.ipt
I would like to assign it to iProperties.Status.Status.
Has anyone any thought about this?
I start to understand iLogic more and more but it is nice to get a little boost in the right direction.
Thanks.
Solved! Go to Solution.
Solved by jletcher. Go to Solution.
Here you go
This will not count the main assembly if you have two main assemblies and want the parts count to be correct you have to run this from a dummy assembly with two main assemblies. After running the rule you have to save and then you can delete the dummy assembly and the part count will be correct.
Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document If openDoc.DocumentType = 12291 Then For Each docFile In openDoc.AllReferencedDocuments 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 If IsNumeric(iProperties.Value(docFName, "Status", "Status")) = False Then iProperties.Value(docFName, "Status", "Status") = 0 End If If partQty.Count <> iProperties.Value(docFName, "Status", "Status") Then iProperties.Value(docFName, "Status", "Status") = partQty.Count End If 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
Hello James,
It works like a charm. Can I ask you for one more thing.
Could you be so kind and write remarks between the codelines so I can understand/learn what they do.
Thanks again.
Toon
hi james is it possibel to modify the code. to count parts with the same partnumber, like partnumber row merge in the bom, i would like to count number of frammeber occurrences, and write it to an iproperty field
M. TOpholm Denmark
Hi James,
I have the same problem in that I need to count the number of parts by the same partnumber not the filename, is this possible. I have multiple subassemblies that have been copied with thier ilogic rule using Design Copy but some of the parts will remain unchanged even though they have unique filenames.
This would be a huge help to me.......
Thanks in Advance
Travis