Modifying a Cylinder using Inventor API C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the following code for obtaining the cylindrical faces in the open geometry. I want to modify the radius of the cylinder. How should I proceed with this?
public static void HoleList(Inventor.Application mApplication)
{
PartDocument doc = (PartDocument)mApplication.ActiveDocument;
PartComponentDefinition PartCompDef = doc.ComponentDefinition;
SurfaceBody body = PartCompDef.SurfaceBodies[1];
int holeCount = 0;
int count = body.Faces.Count;
foreach (Face face in body.Faces)
{
if (face.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
{
holeCount++;
Cylinder cylinder = (Cylinder)face.Geometry;
double ddepth = 0.0;
if (cylinder.AxisVector.Z == 1 || cylinder.AxisVector.Z == -1)
{
ddepth = System.Math.Abs(System.Math.Abs(face.Vertices[1].Point.Z) - System.Math.Abs(face.Vertices[2].Point.Z)) * 10;
}
else if (cylinder.AxisVector.Y == 1)
{
ddepth = System.Math.Abs(System.Math.Abs(face.Vertices[1].Point.Y) - System.Math.Abs(face.Vertices[2].Point.Y)) * 10;
}
else if (cylinder.AxisVector.X == 1)
{
ddepth = System.Math.Abs(System.Math.Abs(face.Vertices[1].Point.X) - System.Math.Abs(face.Vertices[2].Point.X)) * 10;
}
double diameter = 2 * cylinder.Radius;
Console.WriteLine("Diameter: " + cylinder.Radius * 2 * 10 + " mm" + "\t" + "Depth: " + ddepth + " mm");
foreach(Edge edge in face.Edges)
{
Console.WriteLine(edge.StartVertex.Point.X + " " + edge.StartVertex.Point.Y + " " + edge.StartVertex.Point.Z);
Console.WriteLine(edge.StopVertex.Point.X + " " + edge.StopVertex.Point.Y + " " + edge.StopVertex.Point.Z);
}
}
}
}
}
Any help will be greatly appreciated. Thank you.