Create circular pattern feature

Create circular pattern feature

Anonymous
Not applicable
3,917 Views
13 Replies
Message 1 of 14

Create circular pattern feature

Anonymous
Not applicable

Hello,

 

I'm looking some sample code to create a circular pattern feature using the API.

A simple extruded cut patterned around a center axis is what i'm going for.

Does anyone have any experience with something like this?

 

Thanks,

Rob

0 Likes
Accepted solutions (2)
3,918 Views
13 Replies
Replies (13)
Message 2 of 14

Curtis_Waguespack
Consultant
Consultant

Hi ROBTRONIX,

 

I had this iLogic example on hand, hopefully you can convert it to straight VB or what ever is needed.

 

Attached is an example file in case it helps. (I also attached an example file with some rules that modify patterns in case that is useful.)

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oCdef As ComponentDefinition
oCdef = ThisDoc.Document.ComponentDefinition

Dim objCol As ObjectCollection
objCol = ThisApplication.TransientObjects.CreateObjectCollection

'Feature to be patterned
objCol.Add (oCdef.Features("Extrusion2"))

'convert degrees to radians
oDeg = 360 * 0.0174532925 

'create pattern
'....CircularPatternFeatures.Add(Features in Pattern, Axis, NaturalAxisDirection, Count, Angle, FitWithinAngle)
oCdef.Features.CircularPatternFeatures.Add(objCol, oCdef.WorkAxes.Item("Z Axis"), False, 3, oDeg , True)

 

EESignature

0 Likes
Message 3 of 14

Anonymous
Not applicable

Curtis,

 

We plugged this into VBA with some modification and it worked well, but we're having problems when trying different base features or change the orientation of the base feature.  It seems to be tempermental to the type of geometry being patterened, where as a sculpt pattern will error, but the underlying surface will work. A simple extrusion on a plane parallel to the axis of rotation also generates and error.

 

 See attached modified code (in vba) and ref part file.

 

Thanks,,

Rob

 

 

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 5222 StartFragment: 314 EndFragment: 5190 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Dim oCdef As ComponentDefinition
oCdef = ThisDoc.Document.ComponentDefinition

Dim objCol As ObjectCollection
objCol = ThisApplication.TransientObjects.CreateObjectCollection

'Feature to be patterned
objCol.Add (oCdef.Features("Extrusion4"))

'convert degrees to radians
oDeg = 360 * 0.0174532925 

'create pattern'....CircularPatternFeatures.Add(Features in Pattern, Axis, NaturalAxisDirection, Count, Angle, FitWithinAngle)
oCdef.Features.CircularPatternFeatures.Add(objCol, oCdef.WorkAxes.Item("Z Axis"), False, 3, oDeg , True)

 

 

 

 

Message 4 of 14

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi ROBTRONIX,

 

I think what you're seeing is the result of how the ParentFeatures parameter collection is defined. I don't have much more information than what is in the API help, so hopefully you can interpret it for your needs.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

From the API help:

 

CircularPatternFeatures.Add Method
Parameters 
Description 
ParentFeatures 
ObjectCollection object that contains the features to be patterned. The collection could contain the various part features, sheet metal features, work planes, work axes, work points, or a SurfaceBody. Only the primary (result) surface body, obtained from ComponentDefinition.SurfaceBodies.Item(1) is a valid input. If a SurfaceBody is supplied, the only other objects that can be in the collection are work features and surface part features.
 
AxisEntity 
Input object that returns the axis entity. This can be a linear edge, a work axis, or any face that can define an axis (i.e. every face type except planar and spherical).
 
NaturalAxisDirection 
Input Boolean that defines if the sketch plane X or Y axis is in the same direction as that defined by the input axis entity. True indicates the axis direction is in the same direction as that of the input entity.
 
Count 
Input Variant that defines the number of instances in the pattern.
 
Angle 
Input Variant that defines the angle of the pattern
 
FitWithinAngle 
Input Boolean that indicates how the count and angle are used to space the occurrences. If this value is true then the angle specifies the total sweep made by the pattern and the occurrences are evenly spaced within the angle. If it is false then the angle specifies the angular offset between each occurrence.
 
ComputeType 
Property that that indicates the method of solution for the pattern. If specified as kOptimizedCompute, which is the default, patterns are optimized for faster calculation. If kIdenticalCompute is specified, all occurrences in the pattern use an identical termination, regardless of where they intersect another feature. Use this method to efficiently pattern large numbers of features when the feature being duplicated has a distance termination or terminates on a work plane. If kAdjustToModelCompute is specified, the termination of each occurrence is calculated individually. Computation time can be lengthy for patterns with a large number of occurrences. You must use this method if the parent feature terminates on a model face. 

EESignature

Message 5 of 14

Anonymous
Not applicable
Good afternoon people,

I'm trying to apply a circularPattern of a coil in a Revolve object, but as said this procedure is unstable and, in this case also can not create the circularPattern.
Someone who has had this problem found a solution?
Thank you.
0 Likes
Message 6 of 14

JBerns
Advisor
Advisor

Dear Community,

 

I am trying to create a circular pattern of a feature within a part.

2020-04-27_23-33-03.jpg

I downloaded Curtis' ( @Curtis_Waguespack ) part above and the iLogic rule works as expected in his part.

 

I copied his iLogic rule to my part, substituted the feature name, and then run the code. I get an error, "The parameter is incorrect".

 

I changed the feature name to Extrusion2 as it was in the original code and changed the code back to reference Extrusion2. This time, an "Unspecified error" occurs.

 

Can anyone explain why the errors occur? Part file attached.

 

I noticed a couple other forum threads reported issues creating part feature circular patterns:

https://knowledge.autodesk.com/support/inventor/troubleshooting/caas/sfdcarticles/sfdcarticles/Circu... 

 

https://forums.autodesk.com/t5/inventor-customization/circular-patterns-feature-strange-results/td-p... 

 

Thank you for your time and attention. I look forward to a response.

 

 

Regards,

Jerry

 

 

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 7 of 14

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @JBerns 

To add a circular pattern you first need to create a definition for it.

Also there is a bug with the angle so you have to set it after the feature is created and update the part.

 

See ilogic code below:

Dim oCdef As PartComponentDefinition
oCdef = ThisDoc.Document.ComponentDefinition

Dim objCol As ObjectCollection
objCol = ThisApplication.TransientObjects.CreateObjectCollection
'Feature to be patterned
Dim oFeature As ExtrudeFeature = oCdef.Features.ExtrudeFeatures.Item("WeldTabExtude")

objCol.Add(oFeature)


oDeg = "360 deg"

'create pattern
Dim featureDef As CircularPatternFeatureDefinition = oCdef.Features.CircularPatternFeatures.CreateDefinition(objCol, oCdef.WorkAxes.Item("Z Axis"), True, 3, oDeg, True)
Dim oPattern As CircularPatternFeature = oCdef.Features.CircularPatternFeatures.AddByDefinition(featureDef)

'------------------------There is a bug with the angle. Fix it like this!------------------------------------
Dim oDegParam As ModelParameter = oCdef.Parameters.ModelParameters(oCdef.Parameters.ModelParameters.Count)
oDegParam.Expression = oDeg
iLogicVb.UpdateWhenDone = True
'------------------------------------------------------------------------------------------------------------

I'll also attach an edited ipt.

Message 8 of 14

JBerns
Advisor
Advisor

Brilliant, @JhoelForshav !

 

Your code corrections work well.

 

I can't understand why Curtis' code works without first creating the circular pattern definition. I could not find information on the "Add" method. Is this an undocumented method, but still supported?

 

oCdef.Features.CircularPatternFeatures.Add(objCol, oCdef.WorkAxes.Item("Z Axis"), False, 3, oDeg , True)

 

Thanks again, Jhoel for the code update and to @Curtis_Waguespack  Curtis for the original code.

One structural shape complete, two more to go.

2020-04-22_8-58-58.png

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 9 of 14

JhoelForshav
Mentor
Mentor

@JBerns 

I'm super confused about this aswell...

Since Curtis provided this example the method CircularPatternFeatures.Add has disappeared from the documentation.

http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-1A3ABEC4-D07A-4A7A-AA02-7151C7A2DE7D

 

His part still works like you said. I also tried to create a new part and the same code works fine. I guess it still exists but isn't documented anymore.

Couln't get it to work in your part though...

0 Likes
Message 10 of 14

JBerns
Advisor
Advisor

Ackn.

 

Perhaps @Curtis_Waguespack can explain why the code works in his part, but not in others. Maybe someone from Autodesk?

Even without an explanation, I can continue my progress. Thanks again.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 11 of 14

Curtis_Waguespack
Consultant
Consultant

Hi @JBerns 

 

It appears that AD removed the CircularPatternFeatures.Add method in Inventor 2017:

 

https://adndevblog.typepad.com/manufacturing/inventor/page/4/

 

Using the AddByDefinition method that jhoel.forshav shows is the way to go now.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

EESignature

0 Likes
Message 12 of 14

Curtis_Waguespack
Consultant
Consultant

@JBerns wrote:

 

One structural shape complete, two more to go.

2020-04-22_8-58-58.png

 

Regards,

Jerry


Hi @JBerns 

 

You should be able to use a circular pattern for the square shape too... what are you thinking for the rectangle?

EESignature

0 Likes
Message 13 of 14

JBerns
Advisor
Advisor

Thanks, @Curtis_Waguespack, for the explanation. I'll review the post and the content in the API Help "What's New".

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 14 of 14

InventorUser123456
Contributor
Contributor

I'm going crazy trying to figure out why the angle argument isn't working and I have to find out about an API bug on a comment in the Inventor forums. That's wild. Thank you, though.

0 Likes