Rectangular Pattern of Feature vs Solid Body

Rectangular Pattern of Feature vs Solid Body

dominiek_vanwest
Advocate Advocate
514 Views
5 Replies
Message 1 of 6

Rectangular Pattern of Feature vs Solid Body

dominiek_vanwest
Advocate
Advocate

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

0 Likes
Accepted solutions (1)
515 Views
5 Replies
Replies (5)
Message 2 of 6

dominiek_vanwest
Advocate
Advocate

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.

0 Likes
Message 3 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

@dominiek_vanwest,

 

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



0 Likes
Message 4 of 6

dominiek_vanwest
Advocate
Advocate

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.

0 Likes
Message 5 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@dominiek_vanwest,

 

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



0 Likes
Message 6 of 6

dominiek_vanwest
Advocate
Advocate

Thank you very much Chandra, that did help me!

0 Likes