private void button1_Click(object sender, EventArgs e) { //List<Pnt> pList = new List<Pnt>(); List <HybridShapeTypeLib.Point> pList = new List <HybridShapeTypeLib.Point>(); //prtDoc = (PartDocument)catia.Documents.Item(1); prtDoc = (PartDocument)catia.Documents.Add("Part"); Part prt = prtDoc.Part; HybridBodies hbdys = prt.HybridBodies; HybridBody hbdy = hbdys.Add(); hbdy.set_Name("saori"); HybridShapeFactory hsFac = (HybridShapeFactory)prt.HybridShapeFactory; //string Line = textBox1.Text; string lin = ""; if (textBox1.Text == "") { MessageBox.Show("좌표를 입력해주새요"); return; } for (int i = 0; i < textBox1.Lines.Length; i++) { lin = textBox1.Lines[i]; string[] token = lin.Split(','); int x = int.Parse(token[0]); int y = int.Parse(token[1]); int z = int.Parse(token[2]); // pList.Add(new Pnt(x, y, z)); pList.Add(hsFac.AddNewPointCoord(x, y, z)); HybridShapeTypeLib.Point p = hsFac.AddNewPointCoord(x, y, z); //create a point hbdy.AppendHybridShape(p); } //create points and spline HybridShapeSpline splin = hsFac.AddNewSpline(); foreach (HybridShapeTypeLib.Point p in pList) { INFITF.Reference r = prt.CreateReferenceFromGeometry(p); // hsFac.AddNewPointDatum(r); //hbdy.AppendHybridShape(p); splin.AddPoint(r); } hbdy.AppendHybridShape(splin); prt.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(); }
static void Main(string[] args) { INFITF.Application catia; try { catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch (Exception) { catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); } catia.Visible = true; PartDocument prtdoc = (PartDocument)catia.Documents.Add("Part"); Part prt = prtdoc.Part; HybridBodies hbdys = prt.HybridBodies; HybridBody hbdy = hbdys.Add(); HybridShapeFactory hsFac = (HybridShapeFactory)prt.HybridShapeFactory; Point p1 = hsFac.AddNewPointCoord(10, 60, 30); Point p2 = hsFac.AddNewPointCoord(70, 75, 35); Point p3 = hsFac.AddNewPointCoord(100, 80, 30); Point p4 = hsFac.AddNewPointCoord(100, 80, 40); Point p5 = hsFac.AddNewPointCoord(95, 20, 45); Point p6 = hsFac.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 hspln1 = hsFac.AddNewSpline(); HybridShapeSpline hspln2 = hsFac.AddNewSpline(); hspln1.AddPoint(r1); hspln1.AddPoint(r2); hspln1.AddPoint(r3); hspln2.AddPoint(r4); hspln2.AddPoint(r5); hspln2.AddPoint(r6); hbdy.AppendHybridShape(hspln1); hbdy.AppendHybridShape(hspln2); INFITF.Reference rspl1 = prt.CreateReferenceFromGeometry(hspln1); INFITF.Reference rspl2 = prt.CreateReferenceFromGeometry(hspln2); HybridShapeSweepExplicit swp = hsFac.AddNewSweepExplicit(rspl1, rspl2); hbdy.AppendHybridShape(swp); Point p = hsFac.AddNewPointCoord(50, 30, 100); hbdy.AppendHybridShape(p); HybridShapeProject prjct = hsFac.AddNewProject((INFITF.Reference)p, (INFITF.Reference)swp); hbdy.AppendHybridShape(prjct); prt.Update(); }