// 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); }
public TransCAD.Reference GetTransCADSketchReference(MECMOD.Sketch cSketch) { object[] axis = new object[9]; cSketch.GetAbsoluteAxisData(axis); Tool.Round(axis); string cSketchName = cSketch.get_Name(); TransCAD.Reference tRef = null; // CATIA 스케치 좌표계로부터 TransCAD에서 알맞은 레퍼런스를 선택 // 만약, CATIA 스케치 레퍼런스 이름을 얻어올 수 있으면 다른 방식으로 처리 가능 if (GetTransCADPlaneType(axis) == 1) // YZ 평면 { if (axis.GetValue(0).Equals(0.0)) // X 좌표가 0일 때 { tRef = PartManager.tPart.SelectObjectByName("YZPlane"); } else { // 면 선택 tRef = PartManager.tPart.SelectPlaneByAxis((double)axis.GetValue(0), (double)axis.GetValue(1), (double)axis.GetValue(2), (double)axis.GetValue(3), (double)axis.GetValue(4), (double)axis.GetValue(5), (double)axis.GetValue(6), (double)axis.GetValue(7), (double)axis.GetValue(8)); // 새평면 생성 if (tRef == null) { tRef = PartManager.tPart.SelectObjectByName("YZPlane"); double offset = (double)axis.GetValue(0); TransCAD.StdDatumPlaneOffsetFeature tDatum = null; if (offset > 0.0) { tDatum = PartManager.tFeatures.AddNewDatumPlaneOffsetFeature("Plane for " + cSketchName, tRef, offset, false); } else { tDatum = PartManager.tFeatures.AddNewDatumPlaneOffsetFeature("Plane for " + cSketchName, tRef, Math.Abs(offset), true); } tRef = PartManager.tPart.SelectObjectByName(tDatum.Name); } } } else if (GetTransCADPlaneType(axis) == 0) // XY 평면 { if (axis.GetValue(2).Equals(0.0)) // Z좌표가 0일 때 { tRef = PartManager.tPart.SelectObjectByName("XYPlane"); } else { // 면 선택 tRef = PartManager.tPart.SelectPlaneByAxis((double)axis.GetValue(0), (double)axis.GetValue(1), (double)axis.GetValue(2), (double)axis.GetValue(3), (double)axis.GetValue(4), (double)axis.GetValue(5), (double)axis.GetValue(6), (double)axis.GetValue(7), (double)axis.GetValue(8)); // 새평면 생성 if (tRef == null) { tRef = PartManager.tPart.SelectObjectByName("XYPlane"); double offset = (double)axis.GetValue(2); TransCAD.StdDatumPlaneOffsetFeature tDatum = null; if (offset > 0.0) { tDatum = PartManager.tFeatures.AddNewDatumPlaneOffsetFeature("Plane for " + cSketchName, tRef, offset, false); } else { tDatum = PartManager.tFeatures.AddNewDatumPlaneOffsetFeature("Plane for " + cSketchName, tRef, Math.Abs(offset), true); } tRef = PartManager.tPart.SelectObjectByName(tDatum.Name); } } } else if (GetTransCADPlaneType(axis) == 2) // ZX 평면 { if (axis.GetValue(1).Equals(0.0)) // Y좌표가 0일 때 { tRef = PartManager.tPart.SelectObjectByName("ZXPlane"); } else { // 면 선택 tRef = PartManager.tPart.SelectPlaneByAxis((double)axis.GetValue(0), (double)axis.GetValue(1), (double)axis.GetValue(2), (double)axis.GetValue(3), (double)axis.GetValue(4), (double)axis.GetValue(5), (double)axis.GetValue(6), (double)axis.GetValue(7), (double)axis.GetValue(8)); // 새평면 생성 if (tRef == null) { tRef = PartManager.tPart.SelectObjectByName("ZXPlane"); double offset = (double)axis.GetValue(1); TransCAD.StdDatumPlaneOffsetFeature tDatum = null; if (offset > 0.0) { tDatum = PartManager.tFeatures.AddNewDatumPlaneOffsetFeature("Plane for " + cSketchName, tRef, offset, false); } else { tDatum = PartManager.tFeatures.AddNewDatumPlaneOffsetFeature("Plane for " + cSketchName, tRef, Math.Abs(offset), true); } tRef = PartManager.tPart.SelectObjectByName(tDatum.Name); } } } else // 이 외의 경우 { tRef = PartManager.tPart.SelectPlaneByAxis((double)axis.GetValue(0), (double)axis.GetValue(1), (double)axis.GetValue(2), (double)axis.GetValue(3), (double)axis.GetValue(4), (double)axis.GetValue(5), (double)axis.GetValue(6), (double)axis.GetValue(7), (double)axis.GetValue(8)); // 새 평면 생성 if (tRef == null) { TransCAD.StdDatumPlaneOffsetFeature tDatum = PartManager.tFeatures.AddNewDatumPlaneOffsetFeature2("Plane for " + cSketchName, (double)axis.GetValue(0), (double)axis.GetValue(1), (double)axis.GetValue(2), (double)axis.GetValue(3), (double)axis.GetValue(4), (double)axis.GetValue(5), (double)axis.GetValue(6), (double)axis.GetValue(7), (double)axis.GetValue(8), false); tRef = PartManager.tPart.SelectObjectByName(tDatum.Name); } } return(tRef); }