private void ResetState() { planeBase = cylinderBase1 = cylinderBase2 = null; planeLocator = prismLocator1 = prismLocator2 = null; corpus = null; shaft = null; horizont = null; }
private bool DoProcessSelection() { ISelectionMgr selectionManager = document.SelectionManager; int quantity = selectionManager.GetSelectedObjectCount(); if (quantity != 3) { ShowMessage("Make sure, what you pick 3 face and try again"); return false; } Debug.WriteLine("selected {0} surface", quantity); for (int i = 1; i <= quantity; ++i) { try { IComponent2 component = selectionManager.GetSelectedObjectsComponent4(i, -1); IFace2 face = selectionManager.GetSelectedObject6(i, -1); IFeature feature = face.IGetFeature(); ISurface surface = face.IGetSurface(); Debug.WriteLine("face {0}. details: materialIdName: {1}, materialUserName: {2}", i, face.MaterialIdName, face.MaterialUserName); Debug.WriteLine("\tfeature details. name: {0}, visible: {1}, description: {2}", feature.Name, feature.Visible, feature.Description); Debug.WriteLine("\tsurface details. isPlane: {0}, isCylinder: {1}", surface.IsPlane(), surface.IsCylinder()); MountFace mountFace = new MountFace(solidWorks.IGetMathUtility()) { Face = face, Component = component }; if (surface.IsPlane() && planeBase == null) { planeBase = mountFace; } else if (surface.IsCylinder()) { if (cylinderBase1 == null) { cylinderBase1 = mountFace; } else if (cylinderBase2 == null) { cylinderBase2 = mountFace; } } } catch (Exception ex) { Debug.WriteLine("process selected faces error: {0}. \n\tstack trace: {1}", ex.Message, ex.StackTrace); return false; }; } ClearSelection(); Debug.WriteLine("processing select of user ... done!"); return true; }