- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have the code below. This code is to check for Hole features in a part.
If I have a pattern of a Solid Body then the code gives an error on the following line (if I have a pattern of any feature the code works fine):
If (TypeOf oRPF.ParentFeatures.Item(1) Is HoleFeature) Then
How can I check to see if I have a pattern of a Solid Body?
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition
Dim oRectPatterns As RectangularPatternFeatures
Set oRectPatterns = oDef.Features.RectangularPatternFeatures
Dim oRPF As RectangularPatternFeature
For Each oRPF In oRectPatterns
If Not oRPF.Suppressed Then
If (TypeOf oRPF.ParentFeatures.Item(1) Is HoleFeature) Then
‘do something
End If
End If
Next
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I actually found a workaround myself, by luck ![]()
If you use this code
For i = 1 To oRPF.ParentFeatures.Count
The Count returns 0 if you have a feature of a Solid Body.
So putting this code in front of the line where I got the error means I will never get to the line.
You could also use this code:
If oRPF.ParentFeatures.Count <> 0 Then
I will not put this as a solution because I would like to know the correct code for checking if a pattern is a pattern of a solid body.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If solid body is used in rectangular pattern, then patternOfBody property of RectangularPatternFeatureDefinition will return true. For more details, refer below help documentation link.
http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-DD0D196A-A598-4EFD-8CD9-ADAEB25558
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you for the reply Chandra. The link you provided does give me a 'Page not found' though.
I also do use Inventor 2018 at the moment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Check this,
http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-DD0D196A-A598-4EFD-8CD9-ADAEB25558AB
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report