
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys,
I have a question about tapped holes. I want to count all tapped holes in a part using iLogic. I'm currently working on a rule that does this and the rule already counts tapped holes and also cuts/extrusions with a thread in them. This is the rule.
Dim oDoc As PartDocument = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition Dim oHole As HoleFeature Dim oHoles As HoleFeatures = oDef.Features.HoleFeatures Dim oThreadFeatures As ThreadFeatures oThreadFeatures = oDef.Features.ThreadFeatures Dim oThreadFeature As ThreadFeature Dim oThreadInfo As ThreadInfo 'Er zit verschil tussen tapped holes die met de hole functie zijn aangebracht en gaten waar een thread in is aangebracht. 'Deze worden afzonderlijk van elkaar bepaald en bij elkaar opgeteld. MessageBox.Show(oThreadFeatures.Count, "Aantal threadfeatures") For Each oHole In oDef.Features.HoleFeatures If oHole.Tapped = True Then i=i+1 End If Next MessageBox.Show(i, "aantal tapgaten") TapgatenTotaal=oThreadFeatures.Count + i MessageBox.Show(TapgatenTotaal, "Totaal aantal tapgaten")
But the holes that are being counted, are all individual holes. When a tapped hole is in a pattern, the rule will count only one hole, the one that is in the model tree above the pattern. I found the rule that is below on the forum to count all holes in a pattern. I tried to modify this rule so it would only count patterns with a tapped hole as parent feature but I couldn't get it to work. I tried the following.
If Not (TypeOf oRP.ParentFeatures.Item(1) Is HoleFeature.Tapped) Then Continue For
But this didn't work. I also tried to put all the tapped holes that are recognized in the first rule in a object collection and the run the pattern rule for each hole in the collection but that didn't work either. The rule fills in all the holes that are in the collection in every available pattern so the outcome is way to high.
Does anyone know how I can modify the rule (or make a new one) so it only counts tapped holes?
'assume rectangular pattern Dim oRectPatterns As RectangularPatternFeatures = oDef.Features.RectangularPatternFeatures Dim N As Integer = 0 'counter For Each oRP As RectangularPatternFeature In oRectPatterns 'consider only hole patterns If Not (TypeOf oRP.ParentFeatures.Item(1) Is HoleFeature) Then Continue For For Each oFPE As FeaturePatternElement In oRP.PatternElements If Not oFPE.Suppressed Then N += 1 Next Next 'assume circular pattern Dim oCircPatterns As CircularPatternFeatures = oDef.Features.CircularPatternFeatures For Each oCP As CircularPatternFeature In oCircPatterns 'consider only hole patterns If Not (TypeOf oCP.ParentFeatures.Item(1) Is HoleFeature) Then Continue For For Each oFPE As FeaturePatternElement In oCP.PatternElements If Not oFPE.Suppressed Then N += 1 Next Next MsgBox ("The number of holes in the current part is: " & N)
Regards,
Eric
Solved! Go to Solution.