Listing holes in a face of folded metal |
Top Previous Next |
Here is a face with a hole in it, actually a cut:
If you have that part open you can run this:
public static void Test () { PartDocument PartDoc; try { PartDoc = (PartDocument)m_Inventor.ActiveDocument as PartDocument; if (PartDoc == null) { MessageBox.Show("This is not a part document"); return; } } catch { MessageBox.Show ("not a part doc"); return; }
PartComponentDefinition PartDef = PartDoc.ComponentDefinition; PartFeatures FeatsList = PartDef.Features;
foreach (PartFeature ThisFeature in FeatsList) { if (ThisFeature.Type == ObjectTypeEnum.kCutFeatureObject) { CutFeature CutFeature = (CutFeature)ThisFeature; ProfilePath TheProfile = CutFeature.Definition.Profile[1]; ProfileEntity Ent = TheProfile[1];
Debug.WriteLine ("Profile ent " + Ent.ToString() + " " + Ent.CurveType.ToString());
if (Ent.CurveType == Curve2dTypeEnum.kCircleCurve2d) { Circle2d Circle = (Circle2d)Ent.Curve; Debug.WriteLine("It is a circle of radius " + Circle.Radius.ToString()); } } else if (ThisFeature.Type == ObjectTypeEnum.kFaceFeatureObject) { FaceFeature FaceFeat = (FaceFeature)ThisFeature; MessageBox.Show("FaceFeature " + FaceFeat.ToString() + " name<" + FaceFeat.Name + "> has " + FaceFeat.Faces.Count.ToString() + " faces");
//Faces FacesList = FaceFeat.Faces; //FaceFeat.Definition.
//foreach (Face ThisFace in FacesList) //{ // Face.Edges;
//}
} else { MessageBox.Show("This feature is a " + ThisFeature.Type.ToString()); } } }
And you will get this output in the debug window of the IDE:
Profile ent System.__ComObject kCircleCurve2d It is a circle of radius 0,15.
See also this. |
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)