Message 1 of 3

Not applicable
08-03-2018
05:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey,
We had rules in every part and assembly, now we are trying to change this to 1 rule in the main assembly.
Found a good working rule and added some other properties to it but i'm stuck on the part number
Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'Iterate through all of the occurrences Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef) 'get the units of measure Dim oUOM As UnitsOfMeasure oUOM = oOccurrence.Definition.Document.UnitsOfMeasure 'check for and skip virtual components '(in case a virtual component trips things up) If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then map = Left(ThisDoc.FileName(False),6) & ".xlsx" xls = "C:\VaultWorkspace\Projecten" info = xls & "\" & map Dim Aream As String Aream = Round(iProperties.AreaOfComponent(oOccurrence.Name)/1000000,2) ' Convert the Area to the current document units. Dim strArea As String strArea = Aream & "m²" 'push properties to component's iprops iProperties.Value(oOccurrence.Name, "Custom", "Aream") = strArea iProperties.Value(oOccurrence.Name, "Summary", "Title") = GoExcel.CellValue(info, "Pro-info","C10") iProperties.Value(oOccurrence.Name, "Summary", "Subject") = GoExcel.CellValue("C11") iProperties.Value(oOccurrence.Name, "Summary", "Manager") = GoExcel.CellValue("C41") iProperties.Value(oOccurrence.Name, "Project", "Project") = GoExcel.CellValue("C39")'] iProperties.Value(oOccurrence.Name, "Custom", "Klant") = GoExcel.CellValue("C33") iProperties.Value(oOccurrence.Name, "Custom", "Projectnaam") = GoExcel.CellValue("C10") iProperties.Value(oOccurrence.Name, "Custom", "Subbeschrijving") = GoExcel.CellValue("C11") iProperties.Value(oOccurrence.Name, "Project", "Part Number") = Mid (oOccurrence.Name(0),8,12) iProperties.Value(oOccurrence.Name, "Custom", "Aantal") = ItemQty End If Next ' add properties to head assembly where rule is activated iProperties.Value("Custom", "AREAm") = (Round(iProperties.Area / 1000000,2)) & "m²" iProperties.Value("Summary", "Title") = GoExcel.CellValue(info, "Pro-info","C10") iProperties.Value("Summary", "Subject") = GoExcel.CellValue("C11") iProperties.Value("Summary", "Manager") = GoExcel.CellValue("C41") iProperties.Value("Project", "Project") = GoExcel.CellValue("C39")'] iProperties.Value("Custom", "Klant") = GoExcel.CellValue("C33") iProperties.Value("Custom", "Projectnaam") = GoExcel.CellValue("C10") iProperties.Value("Custom", "Subbeschrijving") = GoExcel.CellValue("C11") GoExcel.Save GoExcel.Close
This is what we had in our old rule:
iProperties.Value("Project", "Part Number") = Mid (ThisDoc.FileName(0),8,12)
But changing ThisDoc.fileName to oOccurence.name does not work
Thanks
Solved! Go to Solution.