public void ErstelleLeereSkizze() { // Factories für das Erzeugen von Modellelementen (Std und Hybrid) SF = (ShapeFactory)myPart.ShapeFactory; HSF = (HybridShapeFactory)myPart.HybridShapeFactory; // geometrisches Set auswaehlen und umbenennen HybridBodies catHybridBodies1 = myPart.HybridBodies; HybridBody catHybridBody1; try { catHybridBody1 = catHybridBodies1.Item("Geometrisches Set.1"); } catch (Exception) { MessageBox.Show("Kein geometrisches Set gefunden! " + Environment.NewLine + "Ein PART manuell erzeugen und ein darauf achten, dass 'Geometisches Set' aktiviert ist.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Information); return; } catHybridBody1.set_Name("Profile"); // neue Skizze im ausgewaehlten geometrischen Set auf eine Offset Ebene legen mySketches = catHybridBody1.HybridSketches; OriginElements catOriginElements = myPart.OriginElements; HybridShapePlaneOffset hybridShapePlaneOffset1 = HSF.AddNewPlaneOffset( (Reference)catOriginElements.PlaneYZ, 90.000000, false); hybridShapePlaneOffset1.set_Name("OffsetEbene"); catHybridBody1.AppendHybridShape(hybridShapePlaneOffset1); myPart.InWorkObject = hybridShapePlaneOffset1; myPart.Update(); HybridShapes hybridShapes1 = catHybridBody1.HybridShapes; Reference catReference1 = (Reference)hybridShapes1.Item("OffsetEbene"); hsp_catiaSkizze = mySketches.Add(catReference1); // Achsensystem in Skizze erstellen ErzeugeAchsensystem(); // Part aktualisieren myPart.Update(); }
static void Main(string[] args) { INFITF.Application catia; //add the reference - catia v5 infiit interface... try { //열려 있는 catia가져오기 catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch (Exception) { //catia 실행하기 catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); catia.Visible = true; } MECMOD.PartDocument prtDoc = (MECMOD.PartDocument)catia.Documents.Add("Part"); MECMOD.Part prt = prtDoc.Part; HybridBodies hybdys = prt.HybridBodies; HybridBody hybdy = hybdys.Add(); HybridShapes hyshps = hybdy.HybridShapes; HybridShapeFactory hyshfac = (HybridShapeFactory)prt.HybridShapeFactory; Point p1 = hyshfac.AddNewPointCoord(10, 60, 30); Point p2 = hyshfac.AddNewPointCoord(70, 75, 35); Point p3 = hyshfac.AddNewPointCoord(100, 80, 30); Point p4 = hyshfac.AddNewPointCoord(100, 80, 40); Point p5 = hyshfac.AddNewPointCoord(95, 20, 45); Point p6 = hyshfac.AddNewPointCoord(100, 10, 50); INFITF.Reference r1 = prt.CreateReferenceFromGeometry(p1); INFITF.Reference r2 = prt.CreateReferenceFromGeometry(p2); INFITF.Reference r3 = prt.CreateReferenceFromGeometry(p3); INFITF.Reference r4 = prt.CreateReferenceFromGeometry(p4); INFITF.Reference r5 = prt.CreateReferenceFromGeometry(p5); INFITF.Reference r6 = prt.CreateReferenceFromGeometry(p6); HybridShapeSpline hyspl1 = hyshfac.AddNewSpline(); HybridShapeSpline hyspl2 = hyshfac.AddNewSpline(); hyspl1.AddPoint(r1); hyspl1.AddPoint(r2); hyspl1.AddPoint(r3); hyspl2.AddPoint(r4); hyspl2.AddPoint(r5); hyspl2.AddPoint(r6); hybdy.AppendHybridShape(hyspl1); hybdy.AppendHybridShape(hyspl2); //AppendHybridShape 만들고 바로 해야 된다 INFITF.Reference rspl1 = prt.CreateReferenceFromGeometry(hyspl1); INFITF.Reference rspl2 = prt.CreateReferenceFromGeometry(hyspl2); HybridShapeSweepExplicit swp = hyshfac.AddNewSweepExplicit(rspl1, rspl2); hybdy.AppendHybridShape(swp); Point p = hyshfac.AddNewPointCoord(50, 30, 100); hybdy.AppendHybridShape(p); HybridShapeProject hsprjct = hyshfac.AddNewProject((INFITF.Reference)p, (INFITF.Reference)swp); prt.Update(); }