static CompareResultStatus StartComparison(ModelDoc2 component1, ModelDoc2 component2) { AssemblyDoc swAsbly; int volumeDiff, faceDiff, areaDiff; double aMinusB, bMinusA, aAndB; object[] bodies; Body2 body1, body2; ModelDoc2 comparePart; int comparisonType; double volumeA, volumeB; VolumeCompareResultStatus result; bool cgAligned; lang = SwApp.GetLang(); Dictionary <string, Info> component1Info; Dictionary <string, Info> component2Info; component1Info = GetInfo(component1); component2Info = GetInfo(component2); comparisonType = CheckComponents(component1, component1Info, component2, component2Info); if (comparisonType == 1) { component1 = Convert2Part(component1, component1Info); component2 = Convert2Part(component2, component2Info); } Logger.Info("Comparing '" + component1Info["Name"].Value + "' with '" + component2Info["Name"].Value + "'"); Program.report.AddDelayedSubSection("'" + component1Info["Title"].Value + "' & '" + component2Info["Title"].Value + "'"); swAsbly = CreateAssembly(); InsertComponents(swAsbly, component1, component2); SaveAsPart(swAsbly, component1Info, component2Info); cgAligned = CheckCG(component1, component2); if (!cgAligned) { Logger.Warn("CG has moved by more than 10%"); Program.report.AddDelayedLine("CG has moved by more than 10%"); } // CloseDocs(new object[] { swAsbly, component1, component2 }); comparePart = SwApp.OpenFile(comparePartPath); bodies = ((PartDoc)comparePart).GetBodies2((int)swBodyType_e.swSolidBody, true); body1 = (Body2)bodies[0]; body2 = (Body2)bodies[1]; volumeA = (body1.GetMassProperties(0))[3]; volumeB = (body2.GetMassProperties(0))[3]; faceDiff = CompareFaces(body1, body2); areaDiff = CompareArea(body1, body2); volumeDiff = CompareVolume(body1, body2); Logger.Info("Volume Compare:\t" + volumeDiff); Logger.Info("Area Compare:\t" + areaDiff); Logger.Info("Faces Compare:\t" + faceDiff); Program.report.AddDelayedLine("Volume Compare:\t" + volumeDiff); Program.report.AddDelayedLine("Area Compare:\t" + areaDiff); Program.report.AddDelayedLine("Faces Compare:\t" + faceDiff); aMinusB = SubstractVolume(comparePart, body1, body2); Logger.Info("Volume A-B: " + aMinusB); Program.report.AddDelayedLine("Volume A-B:\t\t" + aMinusB); bMinusA = SubstractVolume(comparePart, body2, body1); Logger.Info("Volume B-A: " + aMinusB); Program.report.AddDelayedLine("Volume B-A:\t\t" + aMinusB); aAndB = CommonVolume(comparePart, body1, body2); Logger.Info("Volume B&A: " + aAndB); Program.report.AddDelayedLine("Volume B&A:\t\t" + aAndB); // CloseDocs(new object[] { comparePart }); result = casefinder(volumeA, volumeB, volumeDiff, faceDiff, areaDiff, aMinusB, bMinusA, aAndB); if (result == VolumeCompareResultStatus.Identical && cgAligned) { Logger.Info("Geometric result: Identical"); return(CompareResultStatus.Identical); } else if (!cgAligned) { Logger.Info("Geometric result: Similar"); return(CompareResultStatus.Similar); } else { Logger.Info("Geometric result: Different"); return(CompareResultStatus.Different); } }