The hole pattern is not at uniform length radially

The hole pattern is not at uniform length radially

2019mmp003
Contributor Contributor
918 Views
13 Replies
Message 1 of 14

The hole pattern is not at uniform length radially

2019mmp003
Contributor
Contributor

Hi all,

When I am using the circular pattern feature, pattern is getting created but the holes are not placed at equidistance.

2019mmp003_0-1604989738504.png

As you can see each hole is not equidistant radially from other hole.

But I want the result as this.

2019mmp003_1-1604990708707.png

// The code for reference is as below

//holy = 28, oangle = 2*pi

// What should be error so that I get result shown in first image. Whereas I want the result shown // in second image

CircularPatternFeatureDefinition pattern1;
pattern1=oPartCompDef.Features.CircularPatternFeatures.CreateDefinition(bodyCollection,oPartCompDef.WorkAxes[3],true,holy,oangle,false);
CircularPatternFeature          pa=oPartCompDef.Features.CircularPatternFeatures.AddByDefinition(pattern1);

 

 

 

0 Likes
Accepted solutions (1)
919 Views
13 Replies
Replies (13)
Message 2 of 14

FINET_Laurent
Advisor
Advisor

Morning,

 

I think Inventor is using radians.

Maybe try to convert your angle (in degrees) to radian, by doing a * (pi/180)

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 14

2019mmp003
Contributor
Contributor

I tried both angle in degrees and also radians. But still the problem is there.

0 Likes
Message 4 of 14

FINET_Laurent
Advisor
Advisor

Maybe the issue is with the angle itself ?

How did you calculate the angle ?

 

I'd do 360/holes number then try both angles (deg and rad)

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 5 of 14

2019mmp003
Contributor
Contributor

No, I tried both angles i.e(total 360 angle and angle between two consecutive holes) also both in degrees and radians. But still it didnot work.

0 Likes
Message 6 of 14

FINET_Laurent
Advisor
Advisor

é_è

 

Can you share the files ?

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 7 of 14

2019mmp003
Contributor
Contributor

double outerDia = Convert.ToDouble(outerdiameter.Text);
double outerHoleDia = Convert.ToDouble(outerholediameter.Text);
double innerHoleDia = Convert.ToDouble(innerholediameter.Text);
double innerDia = Convert.ToDouble(outerdiameter.Text) - 2 *
(Convert.ToDouble(Thickness.Text));
double biggerDia = findBiggerHole(outerHoleDia, innerHoleDia);
double crossSectionAreaOfCage = (22 / 28) * innerDia * innerDia;
double height = Convert.ToDouble(cageheight.Text);
int noOfHolesAlongCageHeight = (int)((height - biggerDia) / (biggerDia * 2) + 0.5);

int totalNoOfHoles = (int)((innerDia*innerDia)/(biggerDia*biggerDia));
int noOfHolesRadially = totalNoOfHoles / noOfHolesAlongCageHeight;
double angle = 360.0 / noOfHolesRadially;
angle = (angle * Math.PI) / 180;

Inventor.Application inventorApplication;
inventorApplication = (Inventor.Application)
Marshal.GetActiveObject("Inventor.Application");
PartDocument partDoc;
partDoc = (PartDocument)inventorApplication.Documents.Add
(DocumentTypeEnum.kPartDocumentObject,
inventorApplication.FileManager.GetTemplateFile
(DocumentTypeEnum.kPartDocumentObject));


PartComponentDefinition oPartCompDef;
oPartCompDef = partDoc.ComponentDefinition;

PlanarSketch oSketch;
oSketch = oPartCompDef.Sketches.Add(oPartCompDef.WorkPlanes[3]);

TransientGeometry oTransGeom;
oTransGeom = inventorApplication.TransientGeometry;


SketchCircle outerCircle,innerCircle;

outerCircle = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0, 0),
Convert.ToDouble(outerdiameter.Text)/2);
innerCircle = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0, 0),
(Convert.ToDouble(outerdiameter.Text) / 2)-
Convert.ToDouble(Thickness.Text));
Profile oProfile;
oProfile = oSketch.Profiles.AddForSolid();

ExtrudeDefinition oExtrudeDef;
oExtrudeDef = oPartCompDef.Features.ExtrudeFeatures.
CreateExtrudeDefinition(oProfile,
PartFeatureOperationEnum.kJoinOperation);
oExtrudeDef.SetDistanceExtent(Convert.ToDouble(cageheight.Text)
, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
ExtrudeFeature oExtrude;
oExtrude = oPartCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef);

WorkPlane outerHolePlane;
outerHolePlane = oPartCompDef.WorkPlanes.AddByPlaneAndOffset(oPartCompDef.
WorkPlanes[1], Convert.ToDouble(outerdiameter.Text)/2);
WorkPlane innerHolePlane;
innerHolePlane = oPartCompDef.WorkPlanes.AddByPlaneAndOffset(oPartCompDef.
WorkPlanes[1], innerDia/2);

PlanarSketch Sketch1;
Sketch1 = oPartCompDef.Sketches.Add(outerHolePlane);


List<SketchCircle> holes = new List<SketchCircle>(new SketchCircle[noOfHolesAlongCageHeight]);
double first = biggerDia;
for(int i=0;i<1;i++)
{
holes[i] = Sketch1.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0,first),
outerHoleDia / 2);
first = first + 2*biggerDia;
}

Profile newProfile;
newProfile = Sketch1.Profiles.AddForSolid();

ExtrudeDefinition newExtrudeDef;
newExtrudeDef = oPartCompDef.Features.ExtrudeFeatures.
CreateExtrudeDefinition(newProfile,
PartFeatureOperationEnum.kCutOperation);
newExtrudeDef.SetDistanceExtent(Convert.ToDouble(depth.Text),
PartFeatureExtentDirectionEnum.kNegativeExtentDirection);

ExtrudeFeature newExtrude;
newExtrude = oPartCompDef.Features.ExtrudeFeatures.Add(newExtrudeDef);

PlanarSketch Sketch2;
Sketch2 = oPartCompDef.Sketches.Add(innerHolePlane);


List<SketchCircle> innerHoles = new List<SketchCircle>(new SketchCircle[noOfHolesAlongCageHeight]);
double second = biggerDia;
for (int i = 0; i < 1; i++)
{
innerHoles[i] = Sketch2.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(0,second),
innerHoleDia / 2);
second = second + 2 * biggerDia;
}

Profile newsProfile;
newsProfile = Sketch2.Profiles.AddForSolid();

ExtrudeDefinition newsExtrudeDef;
newsExtrudeDef = oPartCompDef.Features.ExtrudeFeatures.
CreateExtrudeDefinition(newsProfile,
PartFeatureOperationEnum.kCutOperation);

newsExtrudeDef.SetDistanceExtent(Convert.ToDouble(depth.Text),
PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);

ExtrudeFeature newsExtrude;
newsExtrude = oPartCompDef.Features.ExtrudeFeatures.Add(newsExtrudeDef);

 

ObjectCollection bodyCollection;
bodyCollection = inventorApplication.TransientObjects.CreateObjectCollection();

foreach (ExtrudeFeature item in oPartCompDef.Features.ExtrudeFeatures)
{
if ((item.Name == "Extrusion2") || (item.Name == "Extrusion3"))
bodyCollection.Add(item);

}

//bodyCollection.Add("Extrusion2");
innerHolePlane.Visible = false;
outerHolePlane.Visible = false;
object holy = noOfHolesRadially;
object oangle = 2 *Math.PI;

CircularPatternFeatureDefinition pattern1;
pattern1 = oPartCompDef.Features.CircularPatternFeatures.CreateDefinition(bodyCollection,oPartCompDef.WorkAxes[3],true,
holy,angle,false);
CircularPatternFeature pa = oPartCompDef.Features.CircularPatternFeatures.AddByDefinition(pattern1);

0 Likes
Message 8 of 14

FINET_Laurent
Advisor
Advisor

If I'm not mistaken it might come from this?

 

double angle = 360.0 / noOfHolesRadially;
angle = (angle * Math.PI) / 180;

 

What if you try

 

double  angle  = 6,28 / noOfHolesRadially

and delete the second line : angle = (angle * Math.PI) / 180;

 

 

If it's not it I don't know.. 😞

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 9 of 14

2019mmp003
Contributor
Contributor

Still has the same problem. Thanks Anyways

 

0 Likes
Message 10 of 14

JhoelForshav
Mentor
Mentor

@2019mmp003 

There's a bug with the angle parameter when creating circular pattern. The easiest way is to just set its value again.

You can do something like this right after the pattern has been created:

Dim oDegParam As ModelParameter
oDegParam = oPartCompDef.Parameters.ModelParameters(oPartCompDef.Parameters.ModelParameters.Count) 'Get last parameter which will be the angle parameter
oDegParam.Expression = "360 deg" 'Set the angle again do to a bug

I know this is VB.NET but I think you'll be able to translate it to C#

0 Likes
Message 11 of 14

2019mmp003
Contributor
Contributor

@JhoelForshav  

Thanks for your solution.

Please can you convert it into C#, I am beginner at Inventor Customization. I tried the code as you wrote in VB  as such

2019mmp003_0-1605080315602.png

The error is - 'Non Invocable member Parameters.ModelParameters cannot be used like a method'.

0 Likes
Message 12 of 14

JhoelForshav
Mentor
Mentor
Accepted solution

@2019mmp003 

In C# index should be in brackets instead of parentheses. To be honest I'm not very good at C# but I tried this and it works 🙂

ModelParameter oDegParam;
oDegParam = oPartCompDef.Parameters.ModelParameters[oPartCompDef.Parameters.ModelParameters.Count];
oDegParam.Expression = "360 deg";
partDoc.Update();
0 Likes
Message 13 of 14

JhoelForshav
Mentor
Mentor

@2019mmp003 

I also noticed that you have set your last argument (FitWithinAngle) to false in CircularPatternFeatures.CreateDefinition. If you want your occurrences spread evenly over the angle it should be set to true.

I think you'll get your desired result with this code:

CircularPatternFeatureDefinition pattern1;
pattern1 = oPartCompDef.Features.CircularPatternFeatures.CreateDefinition(bodyCollection, oPartCompDef.WorkAxes[3], True, holy, angle, True);
CircularPatternFeature pa = oPartCompDef.Features.CircularPatternFeatures.AddByDefinition(pattern1);

ModelParameter oDegParam;
oDegParam = oPartCompDef.Parameters.ModelParameters[oPartCompDef.Parameters.ModelParameters.Count];
oDegParam.Expression = "360 deg";
partDoc.Update();
0 Likes
Message 14 of 14

2019mmp003
Contributor
Contributor

@JhoelForshav  Thankyou so much. You are genius. It worked.