public string GetSketchElementNameByReportName(string cSketchName, string cReportName) { string cSketchElementName = null; for (int i = 1; i <= PartManager.cSketches.Count; ++i) { MECMOD.Sketch cSketch = PartManager.cSketches.Item(i); // 해당 스케치면 진입 if (cSketch.get_Name() == cSketchName) { // 해당 스케치의 스케치 요소 탐색 for (int j = 1; j <= cSketch.GeometricElements.Count; ++j) { MECMOD.GeometricElement cGeom = cSketch.GeometricElements.Item(j); string cTempReportName = null; if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeLine2D) { cTempReportName = ((MECMOD.Line2D)cGeom).ReportName.ToString(); } else if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeCircle2D) { cTempReportName = ((MECMOD.Circle2D)cGeom).ReportName.ToString(); } else if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeEllipse2D) { cTempReportName = ((MECMOD.Ellipse2D)cGeom).ReportName.ToString(); } else if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeHyperbola2D) { cTempReportName = ((MECMOD.Hyperbola2D)cGeom).ReportName.ToString(); } else if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeParabola2D) { cTempReportName = ((MECMOD.Parabola2D)cGeom).ReportName.ToString(); } else if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeSpline2D) { cTempReportName = ((MECMOD.Spline2D)cGeom).ReportName.ToString(); } // ReportName이 동일하면 해당 요소의 이름을 리턴 if (cTempReportName == cReportName) { cSketchElementName = cGeom.get_Name(); break; } } break; } } return(cSketchElementName); }
// Pre public void TranslateC2T(MECMOD.GeometricElement cGeom) { MECMOD.Circle2D cCircle = (MECMOD.Circle2D)cGeom; string cCircleName = cCircle.get_Name(); object[] StartCoords = new object[2]; object[] EndCoords = new object[2]; object[] CenterCoords = new object[2]; cCircle.StartPoint.GetCoordinates(StartCoords); cCircle.EndPoint.GetCoordinates(EndCoords); cCircle.GetCenter(CenterCoords); double cRadius = cCircle.Radius; // 반올림 (TransCAD에 2D 제약조건이 없어서 현재는 반드시 필요) Tool.Round(CenterCoords); Tool.Round(StartCoords); Tool.Round(EndCoords); // Circle인 경우 if (Math.Abs((double)StartCoords.GetValue(0) - (double)EndCoords.GetValue(0)) < 0.00001 && Math.Abs((double)StartCoords.GetValue(1) - (double)EndCoords.GetValue(1)) < 0.00001) { SketchManager.tSketchEditor.Create2DCircleCenterPoint(cCircleName, (double)CenterCoords.GetValue(0), (double)CenterCoords.GetValue(1), cRadius); } else // Arc인 경우 { double param = 0.0; object[] tangency = new object[2]; cCircle.GetTangent(param, tangency); if ((double)tangency.GetValue(1) > 0.0) { SketchManager.tSketchEditor.Create2DArcCenterStartEnd(cCircleName, (double)CenterCoords.GetValue(0), (double)CenterCoords.GetValue(1), (double)StartCoords.GetValue(0), (double)StartCoords.GetValue(1), (double)EndCoords.GetValue(0), (double)EndCoords.GetValue(1)); } else { SketchManager.tSketchEditor.Create2DArcCenterStartEnd(cCircleName, (double)CenterCoords.GetValue(0), (double)CenterCoords.GetValue(1), (double)EndCoords.GetValue(0), (double)EndCoords.GetValue(1), (double)StartCoords.GetValue(0), (double)StartCoords.GetValue(1)); } } }
// Pre public void TranslateC2T(MECMOD.GeometricElement cGeom) { MECMOD.Line2D cLine = (MECMOD.Line2D)cGeom; object[] StartCoords = new object[2]; object[] EndCoords = new object[2]; string cLineName = cLine.get_Name(); cLine.StartPoint.GetCoordinates(StartCoords); cLine.EndPoint.GetCoordinates(EndCoords); if (cLine == SketchManager.cCenterLine) // Centerline인 경우 { SketchManager.tSketchEditor.Create2DCenterline2Points(cLineName, (double)StartCoords.GetValue(0), (double)StartCoords.GetValue(1), (double)EndCoords.GetValue(0), (double)EndCoords.GetValue(1)); } else // 일반 Line인 경우 { SketchManager.tSketchEditor.Create2DLine2Points(cLineName, (double)StartCoords.GetValue(0), (double)StartCoords.GetValue(1), (double)EndCoords.GetValue(0), (double)EndCoords.GetValue(1)); } }
// Pre public void TranslateC2T(MECMOD.Sketch cSketch) { string sketchName = cSketch.get_Name(); MECMOD.GeometricElements cGeoms = cSketch.GeometricElements; cCenterLine = cSketch.CenterLine; object[] cCoords = new object[9]; cSketch.GetAbsoluteAxisData(cCoords); TransCAD.Reference tSktReference = PartManager.ReferenceManager.GetTransCADSketchReference(cSketch); TransCAD.StdSketchFeature tSketch = PartManager.tFeatures.AddNewSketchFeature(sketchName, tSktReference); tSketch.SetCoordinateSystem((double)cCoords.GetValue(0), (double)cCoords.GetValue(1), (double)cCoords.GetValue(2), (double)cCoords.GetValue(3), (double)cCoords.GetValue(4), (double)cCoords.GetValue(5), (double)cCoords.GetValue(6), (double)cCoords.GetValue(7), (double)cCoords.GetValue(8)); tSketchEditor = tSketch.OpenEditorEx(false); for (int i = 1; i <= cGeoms.Count; i++) { MECMOD.GeometricElement cGeom = cGeoms.Item(i); if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeLine2D) { SketchLine2D line2D = new SketchLine2D(this); line2D.TranslateC2T(cGeom); } else if (cGeom.GeometricType == MECMOD.CatGeometricType.catGeoTypeCircle2D) { SketchCircle2D circle2D = new SketchCircle2D(this); circle2D.TranslateC2T(cGeom); } } tSketchEditor.Close(); tReference = PartManager.tPart.SelectObjectByName(sketchName); }
// Post public void TranslateT2C(TransCAD.IFeature tFeature) { TransCAD.IStdSketchFeature tSketch = (TransCAD.IStdSketchFeature)tFeature; string sketchName = tSketch.Name; TransCAD.IStdSketchGeometries tGeoms = tSketch.Geometries; double[] coords = new double[9]; object[] tCoords = new object[9]; tSketch.GetCoordinateSystem(out coords[0], out coords[1], out coords[2], out coords[3], out coords[4], out coords[5], out coords[6], out coords[7], out coords[8]); for (int i = 0; i < 9; ++i) { tCoords[i] = coords[i]; } INFITF.Reference cSktReference = PartManager.ReferenceManager.GetCATIASketchReference(tSketch); MECMOD.Sketch cSketch = PartManager.cSketches.Add(cSktReference); cSketch.SetAbsoluteAxisData(tCoords); cFactory = cSketch.OpenEdition(); // 스케치 로컬 좌표 축 설정 MECMOD.GeometricElement axis = cSketch.GeometricElements.Item("AbsoluteAxis"); INFITF.CATBaseDispatch localX = axis.GetItem("HDirection"); MECMOD.Line2D locX = (MECMOD.Line2D)localX; locX.ReportName = ++cReportName; INFITF.CATBaseDispatch localY = axis.GetItem("VDirection"); MECMOD.Line2D locY = (MECMOD.Line2D)localY; locX.ReportName = ++cReportName; IEnumerator tGeomList = tGeoms.GetEnumerator(); while (tGeomList.MoveNext()) { TransCAD.IStdSketchGeometry tGeom = (TransCAD.IStdSketchGeometry)tGeomList.Current; if (tGeom.Type == TransCAD.StdSketchGeometryType.Line || tGeom.Type == TransCAD.StdSketchGeometryType.Centerline) { SketchLine2D line2D = new SketchLine2D(this); line2D.TranslateT2C(tGeom); if (tGeom.Type == TransCAD.StdSketchGeometryType.Centerline) { cSketch.CenterLine = cCenterLine; } } else if (tGeom.Type == TransCAD.StdSketchGeometryType.Circle || tGeom.Type == TransCAD.StdSketchGeometryType.CircularArc) { SketchCircle2D circle2D = new SketchCircle2D(this); circle2D.TranslateT2C(tGeom); } } cSketch.CloseEdition(); cReference = PartManager.cPart.CreateReferenceFromObject(cSketch); PartManager.cPart.InWorkObject = cSketch; PartManager.cPart.UpdateObject(cSketch); PartManager.ReferenceManager.NameMap.Add(tSketch.Name, cSketch.get_Name()); }