Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
we make holes in parts in three ways, punching, drilling, and burning. i want to be able to pull this data out of large assembly boms later down the road, so im trying to use ilogic in my start parts to help with cost analysis later.
workflow will be that if holes are "PUNCHED", "DRILLED" OR "BURNED" the user will simply name the feature so it starts with one of those key words, i have the macro just about working, except for where it comes to counting the named features once used in a pattern.
'assume part document Dim oDoc As PartDocument = ThisDoc.Document 'Set oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition 'assume rectangular pattern Dim oRectPatterns As RectangularPatternFeatures = oDef.Features.RectangularPatternFeatures 'assume circular pattern Dim oCircPatterns As CircularPatternFeatures = oDef.Features.CircularPatternFeatures Dim A As Integer = 0 For Each BFeat In oDef.Features.ExtrudeFeatures If BFeat.Name.Contains("BURN") Then A = A + 1 Next iProperties.Value("Custom", "BRN_HOLES") = A ' Calc patterned burned holes Dim B As Integer = 0 'counter For Each oRPPB As RectangularPatternFeature In oRectPatterns 'consider only patterns CONTAINING NAME If oRPPB.ParentFeatures.Item(1).Name.Contains("BURN") Then Continue For For Each oFPEPB As FeaturePatternElement In oRPPB.PatternElements If oFPEPB Is active Then B += 1 Next Next For Each oCPPB As CircularPatternFeature In oCircPatterns 'consider only patterns CONTAINING NAME If oCPPB.ParentFeatures.Item(1).Name.Contains("BURN") Then Continue For For Each oFPEPB As FeaturePatternElement In oCPPB.PatternElements If oFPEPB Is active Then B += 1 Next Next iProperties.Value("Custom", "PTN_BRNS") = B Dim C As Integer = 0 'counter For Each oRPbp As RectangularPatternFeature In oRectPatterns 'consider only hole patterns If oRPbp.ParentFeatures.Item(1).Name.Contains("BURN") Then C += 1 Next For Each oCPbp As CircularPatternFeature In oCircPatterns 'consider only hole patterns If oCPbp.ParentFeatures.Item(1).Name.Contains("BURN") Then C += 1 Next iProperties.Value("Custom", "BRN_PTNS") = C 'WORK WITH DRILLED HOLES Dim D As Integer = 0 For Each DFeat In oDef.Features.ExtrudeFeatures If DFeat.Name.Contains("DRILL") Then D = D + 1 Next iProperties.Value("Custom", "DRL_HOLES") = D ' Calc patterned DRILLED holes Dim E As Integer = 0 'counter For Each oRPPD As RectangularPatternFeature In oRectPatterns 'consider only patterns CONTAINING NAME If oRPPD.ParentFeatures.Item(1).Name.Contains("DRILL") Then Continue For For Each oFPEPD As FeaturePatternElement In oRPPD.PatternElements If oFPEPD Is Active Then E += 1 Next Next For Each oCPPD As CircularPatternFeature In oCircPatterns 'consider only patterns CONTAINING NAME If oCPPD.ParentFeatures.Item(1).Name.Contains("DRILL") Then Continue For For Each oFPEPD As FeaturePatternElement In oCPPD.PatternElements If oFPEPD Is Active Then E += 1 Next Next iProperties.Value("Custom", "PTN_DRLS") = E Dim F As Integer = 0 'counter For Each oRPDp As RectangularPatternFeature In oRectPatterns 'consider only hole patterns If oRPDp.ParentFeatures.Item(1).Name.Contains("DRILL") Then F += 1 Next For Each oCPDp As CircularPatternFeature In oCircPatterns 'consider only hole patterns If oCPDp.ParentFeatures.Item(1).Name.Contains("DRILL") Then F += 1 Next iProperties.Value("Custom", "DRL_PTNS") = F 'WORK WITH PUNCHED HOLES Dim G As Integer = 0 For Each PFeat In oDef.Features.ExtrudeFeatures If PFeat.Name.Contains("PUNCH") Then G = G + 1 Next iProperties.Value("Custom", "PUN_HOLES") = G ' Calc patterned punched holes Dim H As Integer = 0 'counter For Each oRPPP As RectangularPatternFeature In oRectPatterns 'consider only patterns CONTAINING NAME If oRPPP.ParentFeatures.Item(1).Name.Contains("PUNCH") Then Continue For For Each oFPEPP As FeaturePatternElement In oRPPP.PatternElements If Feature.IsActive(oRPPP)=True Then H += 1 Next Next For Each oCPPP As CircularPatternFeature In oCircPatterns 'consider only patterns CONTAINING NAME If oCPPP.ParentFeatures.Item(1).Name.Contains("PUNCH") Then Continue For For Each oFPEPP As FeaturePatternElement In oCPPP.PatternElements If Feature.IsActive(oCPPP)=True Then H += 1 Next Next iProperties.Value("Custom", "PTN_PUNS") = H Dim J As Integer = 0 'counter For Each oRPPPAT As RectangularPatternFeature In oRectPatterns 'consider only hole patterns If oRPPPAT.ParentFeatures.Item(1).Name.Contains("PUNCH") Then J += 1 Next For Each oCPPPAT As CircularPatternFeature In oCircPatterns 'consider only hole patterns If oCPPPAT.ParentFeatures.Item(1).Name.Contains("PUNCH") Then J += 1 Next iProperties.Value("Custom", "PUN_PTNS") = J BURNCOUNT = (iProperties.Value("Custom", "BRN_HOLES") + iProperties.Value("Custom", "PTN_BRNS")) -iProperties.Value("Custom", "BRN_PTNS") iProperties.Value("Custom", "BURNED HOLES") = BURNCOUNT DRILLCOUNT = (iProperties.Value("Custom", "DRL_HOLES") + iProperties.Value("Custom", "PTN_DRLS")) -iProperties.Value("Custom", "DRL_PTNS") iProperties.Value("Custom", "DRILLED HOLES") = DRILLCOUNT PUNCHCOUNT = (iProperties.Value("Custom", "PUN_HOLES") + iProperties.Value("Custom", "PTN_PUNS")) -iProperties.Value("Custom", "PUN_PTNS") iProperties.Value("Custom", "PUNCHED HOLES") = PUNCHCOUNT TOTALCOUNT = iProperties.Value("Custom", "DRILLED HOLES") + iProperties.Value("Custom", "BURNED HOLES") + iProperties.Value("Custom", "PUNCHED HOLES") iProperties.Value("Custom", "HOLES TOTAL") = TOTALCOUNT
Solved! Go to Solution.