Message 1 of 1
Modify the radius of cylinder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hii..I am able to access the surface body and from that faces and cylinder .I can access the radius but not able to modify the radius of cylinder and update that in active document.Here Attaching the code
PartDocument doc = (PartDocument)mApplication.ActiveDocument; PartComponentDefinition compDef = doc.ComponentDefinition; SurfaceBody body = compDef.SurfaceBodies[1]; //SurfaceBody aBody = body.AlternateBody[1]; int cnt = 0; int count= aBody.Faces.Count; foreach (Face face in body.Faces) { if (face.SurfaceType == SurfaceTypeEnum.kCylinderSurface) { cnt++; 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; double newRadius = 0.3; double Area = face.Evaluator.Area; cylinder.Radius = newRadius; doc.Update(); //double depth = GetCylinderDepth(cylinder); }