too many results
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I was wondering if someone would be so kind as to help me with an issue I'm having with one of my rules.
The rule makes flatpatterns from all the sheetmetal parts in an assembly file.
The problem is, it sometimes makes multiple views of one part.
I found a rule found in this form (by Curtis W.) that finds the Total Quantity of a part based on it's MARK_NO. His rule the only one I found in here that can handle the assemblies that have the same problem as this rule I'm asking about. His QTY rule CORRECTLY finds the Total Quantity of each part (all parts, not just sheetmetal) in a top-level assembly. I believe the same problem lies in this flatpattern view rule. Here's his 'sweet' rule:
Class ThisRule
Dim rDoc As Document, oDoc As Document
Dim oQty As Integer
'access top-level assembly BOM
Sub Main()
On Error Resume Next
Dim oAssem As AssemblyDocument = ThisDoc.Document
Dim oBOM As BOM = oAssem.ComponentDefinition.BOM
oBOM.StructuredViewFirstLevelOnly = False
oBOM.StructuredViewEnabled = True
oBOM.PartsOnlyViewEnabled = True
oBOM.SetPartNumberMergeSettings(True, )
For Each oDoc In oAssem.AllReferencedDocuments
'run subs on BOM
oQty = 0
If oDoc.DocumentType = 12291 Then Call ListItems(oBOM.BOMViews.Item(1).BOMRows, 0, oDoc) 'assembly
If oDoc.DocumentType = 12290 Then Call ListItems(oBOM.BOMViews.Item(3).BOMRows, 0, oDoc) 'part
Next
End Sub
'extract total quantity from top-level assembly and insert it into new iProperty "TotalQty"
Sub ListItems(Rows As BOMRowsEnumerator, indent As Integer, oDoc As Document)
For Each oBOMRow As BOMRow In Rows
rDoc = oBOMRow.ComponentDefinitions.Item(1).Document
If rDoc IsNot oDoc Then
If Not oBOMRow.ChildRows Is Nothing Then
Call ListItems(oBOMRow.ChildRows, indent + 1, oDoc)
End If
Else
oQty = oQty + oBOMRow.ItemQuantity
i=1
For Each kDoc In oBOMRow.ComponentDefinitions
rDoc = oBOMRow.ComponentDefinitions.Item(i).Document
rDoc.PropertySets("Inventor User Defined Properties").Item("TotalQty").Value = oQty
i=i+1
Next
End If
Next
End Sub
End Class
Here's how the model is built, which I believe causes the problems:
It's got multiple sub-assemblies with different part file names who share the same MARK_NO (in the BOM). So when the rule searches the BOM for every part according to its MARK_NO, it finds multiple occurrences of each MARK_NO in different sub-assemblies. So when it finds that particular MARK_NO in each sub-assembly, it creates a drg view. But if the top-level assembly does not have multiple sub-assemblies which contain parts sharing the same MARK_NO btw sub-assemblies, the rule works great.
I am hoping to find someone in here who can help me change the below code to filter through all sub-assemblies BEFORE the rule decides to create a drawing view for each part based on its MARK_NO.
'get list of part MARK_NO's to find every sheetmetal part for each view
Dim MarkList As New ArrayList
For Each rDoc As Document In AssyDoc.AllReferencedDocuments
Try
Dim oDef As SheetMetalComponentDefinition = rDoc.ComponentDefinition
If oDef.HasFlatPattern = False Then
oDef.Unfold
oDef.FlatPattern.ExitEdit
rDoc.Close
End If
MarkList.Add(rDoc.PropertySets("Design Tracking Properties").Item("Stock Number").Value)
Catch
End Try
Next
MarkList.Sort()
For Each item In MarkList
For Each rDoc As Document In AssyDoc.AllReferencedDocuments
If rDoc.PropertySets("Design Tracking Properties").Item("Stock Number").Value = item Then
CreateViews(rDoc)
End If
Next
Next
Thanx for considering my request!
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator