public Boolean ErzeugePart() { INFITF.Documents catDocuments1 = hsp_catiaApp.Documents; hsp_catiaPart = catDocuments1.Add("Part") as MECMOD.PartDocument; // hsp_catiaPart.set_Name("Rechteckprofil"); return(true); }
public void erzeugePart() { //erzeuge Part Document partdoc = hsp_catiaApp.Documents.Add("Part"); hsp_catiaPart = (PartDocument)partdoc; }
private void button1_Click(object sender, EventArgs e) { 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; MECMOD.Bodies bdys = prt.Bodies; MECMOD.Body bdy = bdys.Add(); MECMOD.Sketches skts = bdy.Sketches; INFITF.Reference xypln = (INFITF.Reference)prt.OriginElements.PlaneXY; MECMOD.Sketch skt = skts.Add(xypln); MECMOD.Factory2D fac2d = skt.OpenEdition(); Point2D p1 = fac2d.CreatePoint(10, 10); Point2D p2 = fac2d.CreatePoint(10, 40); Point2D p3 = fac2d.CreatePoint(40, 40); Point2D p4 = fac2d.CreatePoint(40, 10); Point2D p5 = fac2d.CreatePoint(30, 20); Point2D p6 = fac2d.CreatePoint(20, 5); Line2D linLft = fac2d.CreateLine(10, 10, 10, 40); Line2D linTop = fac2d.CreateLine(10, 40, 40, 40); Line2D linRgt = fac2d.CreateLine(40, 40, 40, 10); object[] parry = { p1, p6, p5, p4 }; Spline2D spl = fac2d.CreateSpline(parry); linLft.StartPoint = p1; linLft.EndPoint = p2; linRgt.StartPoint = p3; linRgt.EndPoint = p4; linTop.StartPoint = p2; linTop.EndPoint = p3; MECMOD.Constraint cnst = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeAxisPerpendicularity, (INFITF.Reference)linLft, (INFITF.Reference)linTop); /* * INFITF.Reference r1 = prt.CreateReferenceFromGeometry(linLft); * INFITF.Reference r2 = prt.CreateReferenceFromGeometry(linTop); * MECMOD.Constraint cnst1 = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeAxisPerpendicularity, r1, r2); */ skt.CloseEdition(); prt.Update(); }
public Boolean ErzeugePart() { INFITF.Documents catDocuments1 = hsp_catiaApp.Documents; hsp_catiaPartDoc = catDocuments1.Add("Part") as MECMOD.PartDocument; myPart = hsp_catiaPartDoc.Part; return(true); }
internal void ErzeugePart() { //Dokument erstellen catDokuments1 = hsp_catiaApp.Documents; //Part erstellen hsp_catiaPartDoc = (PartDocument)catDokuments1.Add("Part"); }
public bool InitCATIAPart() { try { oPartDoc = (MECMOD.PartDocument)CATIA.ActiveDocument; oPart = oPartDoc.Part; oBodies = oPart.Bodies; oBody = oPart.MainBody; oHBodies = oPart.HybridBodies; oSF = (ShapeFactory)oPart.ShapeFactory; oHSF = (HybridShapeFactory)oPart.HybridShapeFactory; } catch { } return(true); }
public bool InitCATIAPart(bool bNewPart, string strPart) { if (bNewPart) { //初始化 docCATIA = CATIA.Documents; oPartDoc = (MECMOD.PartDocument)docCATIA.Add("Part"); } else { if (strPart.Trim() == "") { oPartDoc = (MECMOD.PartDocument)CATIA.ActiveDocument; if (oPartDoc == null) { docCATIA = CATIA.Documents; oPartDoc = (MECMOD.PartDocument)docCATIA.Add("Part"); } } else { if (System.IO.File.Exists(strPart)) //有文件 { oPartDoc = (MECMOD.PartDocument)CATIA.Documents.Open(strPart); } else { return(false); } } } oPart = oPartDoc.Part; oBodies = oPart.Bodies; oBody = oPart.MainBody; oHBodies = oPart.HybridBodies; oSF = (ShapeFactory)oPart.ShapeFactory; oHSF = (HybridShapeFactory)oPart.HybridShapeFactory; return(true); }
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(); }
public void PartKreis_hohl() { INFITF.Documents Kreis_hohl_Part = CATIA_Kreis_hohl.Documents; CATIA_Kreis_hohl_Part = Kreis_hohl_Part.Add("Part") as MECMOD.PartDocument; }
public void PartSonderU() { INFITF.Documents SonderU_Part = CATIA_SonderU.Documents; CATIA_SonderU_Part = SonderU_Part.Add("Part") as MECMOD.PartDocument; }
// Öffnen einer bestehenden Datei in Catia public void openFile() { hsp_catiaPart = (PartDocument)hsp_catiaApp.Documents.Open(@"C:\Users\Essam Asian Man\Documents\GitHub\Essamstest\Sprint3WPF\Rechteckprofil.CATPart"); }
public void ErzeugePart() { Documents catDocuments = catiaApp.Documents; catiaPart = (PartDocument)catDocuments.Add("Part"); }
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; MECMOD.Bodies bdys = prt.Bodies; MECMOD.Body bdy = bdys.Add(); MECMOD.Sketches skts = bdy.Sketches; INFITF.Reference xypln = (INFITF.Reference)prt.OriginElements.PlaneXY; MECMOD.Sketch skt = skts.Add(xypln); MECMOD.Factory2D fac2d = skt.OpenEdition(); Point2D p1 = fac2d.CreatePoint(50, 50); Point2D p2 = fac2d.CreatePoint(50, 100); Point2D p3 = fac2d.CreatePoint(100, 100); Point2D p4 = fac2d.CreatePoint(100, 50); //method를 만들고 line생성 Line2D lin1 = CreateLine(fac2d, p1, p2); Line2D lin2 = CreateLine(fac2d, p2, p3); Line2D lin3 = CreateLine(fac2d, p3, p4); Line2D lin4 = CreateLine(fac2d, p4, p1); /* * Line2D lin1 = fac2d.CreateLine(50,50,50,100); * Line2D lin2 = fac2d.CreateLine(50, 100, 100, 100); * Line2D lin3 = fac2d.CreateLine(100, 100, 100, 50); * Line2D lin4 = fac2d.CreateLine(100, 50, 50, 50); * * lin1.StartPoint = p1; * lin1.EndPoint = p2; * * lin2.StartPoint = p2; * lin2.EndPoint = p3; * * lin3.StartPoint = p3; * lin3.EndPoint = p4; * * lin4.StartPoint = p4; * lin4.EndPoint = p1; */ INFITF.Reference rline1 = prt.CreateReferenceFromGeometry(lin1); INFITF.Reference rline2 = prt.CreateReferenceFromGeometry(lin2); INFITF.Reference rline3 = prt.CreateReferenceFromGeometry(lin3); INFITF.Reference rline4 = prt.CreateReferenceFromGeometry(lin4); INFITF.Reference rlineH = prt.CreateReferenceFromGeometry(skt.AbsoluteAxis.HorizontalReference); INFITF.Reference rlineV = prt.CreateReferenceFromGeometry(skt.AbsoluteAxis.VerticalReference); Constraint d1 = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline1, rline3); Constraint d2 = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline2, rline4); Constraint d3 = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineH, rline4); Constraint d4 = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineV, rline1); skt.CloseEdition(); }
//Methode zur erstellung eines neuen Parts internal void ErzeugePart() { INFITF.Documents catDocuments1 = hspB1_catiaApp.Documents; hspB1_catiaPart = (PartDocument)catDocuments1.Add("Part"); }
private void button1_Click(object sender, EventArgs e) { 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; MECMOD.Bodies bdys = prt.Bodies; MECMOD.Body bdy = bdys.Add(); MECMOD.Sketches skts = bdy.Sketches; INFITF.Reference xypln = (INFITF.Reference)prt.OriginElements.PlaneXY; Sketch skt1 = skts.Add(xypln); Factory2D fac2d = skt1.OpenEdition(); //fac2d안에서 sketch가 이루어진다. fac2d cketch의 기능을 쓸수있다 Point2D p1 = fac2d.CreatePoint(10, 10); Point2D p2 = fac2d.CreatePoint(10, 30); Point2D p3 = fac2d.CreatePoint(40, 30); Point2D p4 = fac2d.CreatePoint(40, 10); //method를 만들고 line생성 Line2D lin1 = CreateLine(fac2d, p1, p2); Line2D lin2 = CreateLine(fac2d, p2, p3); Line2D lin3 = CreateLine(fac2d, p3, p4); Line2D lin4 = CreateLine(fac2d, p4, p1); CatConstraintType cnstDis = CatConstraintType.catCstTypeDistance; MECMOD.Constraint d1 = createCnst(prt, skt1, cnstDis, lin1, lin3); MECMOD.Constraint d2 = createCnst(prt, skt1, cnstDis, lin2, lin4); MECMOD.Constraint d3 = createCnst(prt, skt1, cnstDis, skt1.AbsoluteAxis.HorizontalReference, lin4); MECMOD.Constraint d4 = createCnst(prt, skt1, cnstDis, skt1.AbsoluteAxis.VerticalReference, lin1); /* * INFITF.Reference rline1 = prt.CreateReferenceFromGeometry(lin1); * INFITF.Reference rline2 = prt.CreateReferenceFromGeometry(lin2); * INFITF.Reference rline3 = prt.CreateReferenceFromGeometry(lin3); * INFITF.Reference rline4 = prt.CreateReferenceFromGeometry(lin4); * INFITF.Reference rlineH = prt.CreateReferenceFromGeometry(skt1.AbsoluteAxis.HorizontalReference); * INFITF.Reference rlineV = prt.CreateReferenceFromGeometry(skt1.AbsoluteAxis.VerticalReference); * * MECMOD.Constraint d1 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline1, rline3); * MECMOD.Constraint d2 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline2, rline4); * MECMOD.Constraint d3 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineH, rline4); * MECMOD.Constraint d4 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineV, rline1); */ skt1.CloseEdition(); //create a circlr Sketch skt2 = skts.Add(xypln); Factory2D fac2d1 = skt2.OpenEdition(); //fac2d = skt2.OpenEdition(); //이렇게 함녀 된다. INFITF.Reference H = prt.CreateReferenceFromGeometry(skt2.AbsoluteAxis.HorizontalReference); INFITF.Reference V = prt.CreateReferenceFromGeometry(skt2.AbsoluteAxis.VerticalReference); Circle2D c = fac2d1.CreateClosedCircle(40, 30, 10); c.CenterPoint = p3; // MECMOD.Constraint orPtH = skt2.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance,H,(INFITF.Reference)c); //MECMOD.Constraint orPtV = skt2.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, V, (INFITF.Reference)c); MECMOD.Constraint r = skt2.Constraints.AddMonoEltCst(CatConstraintType.catCstTypeRadius, (INFITF.Reference)c); skt2.CloseEdition(); ShapeFactory ShpFac = (ShapeFactory)prt.ShapeFactory; //pad Pad pad = ShpFac.AddNewPad(skt1, 20); //poket Pocket pock = ShpFac.AddNewPocket(skt2, 20); pock.DirectionOrientation = CatPrismOrientation.catRegularOrientation; prt.Update(); }
public void PartRechteck_hohl() { INFITF.Documents Rechteck_hohl_Part = CATIA_Rechteck_hohl.Documents; CATIA_Rechteck_hohl_Part = Rechteck_hohl_Part.Add("Part") as MECMOD.PartDocument; }
public CAD(object[] ParameterListe) { // Listen Werte wieder in richtige Datentypen umwandeln int Kopf = Convert.ToInt32(ParameterListe[0]); double Durchmesser = Convert.ToDouble(ParameterListe[1]); double Gewindelänge = Convert.ToDouble(ParameterListe[2]); double Schaftlänge = Convert.ToDouble(ParameterListe[3]); double Steigung = Convert.ToDouble(ParameterListe[4]); int Gewindeart = Convert.ToInt32(ParameterListe[5]); double Schlüsselweite = Convert.ToDouble(ParameterListe[6]); double Kopfhöhe = Convert.ToDouble(ParameterListe[7]); double Kopfdurchmesser = Convert.ToDouble(ParameterListe[8]); string Schraubenrichtung = Convert.ToString(ParameterListe[9]); bool GewindeFeature = Convert.ToBoolean(ParameterListe[10]); bool GewindeHelix = Convert.ToBoolean(ParameterListe[11]); //Hier wird das gesamte Modell erstellt, wenn nichts schief geht try { //Abfrage ob Catia geöffnet ist if (CatiaLaeuft()) { //Erstellt ein neues Part INFITF.Documents catDocuments1 = hsp_catiaApp.Documents; hsp_catiaPart = catDocuments1.Add("Part") as MECMOD.PartDocument; //Erstellt alle Skizzen ErstelleLeereSkizze(); //Erstellt ein Profil vom Kopf ProfilKopf(ParameterListe); //Erstellt einen Block für den Kopf if (Kopf == 1 | Kopf == 2) { BlockKopfErstellen(ParameterListe); } else { RotationskörperErstellen(); } //Erstellt ein Profil für den Schaft ProfilSchaft(ParameterListe); //Erstellt ein Block für den Schaft BlockSchaftErstellen(ParameterListe); if (Kopf == 2 | Kopf == 3) { ErstelleTascheProfil(ParameterListe); ErstelleTasche(ParameterListe); } //Erstellt Gewinde am Schaft if (GewindeFeature) { Gewindefeature(ParameterListe); } if (GewindeHelix) { //makeGewindeSkizze(ParameterListe); ErzeugeGewindeHelix(ParameterListe); } ErstelleFaseProfil(ParameterListe); ErstelleFase(ParameterListe); } else { MessageBox.Show("Laufende Catia Application nicht gefunden"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception aufgetreten"); } }
private void button1_Click(object sender, EventArgs e) { INFITF.Application Catia; try { Catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); } catch { Catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application")); Catia.Visible = true; } INFITF.Documents Docts = Catia.Documents; MECMOD.PartDocument PrtDoc = (MECMOD.PartDocument)Docts.Add("Part"); MECMOD.Part Prt = PrtDoc.Part; MECMOD.Bodies Bodis = Prt.Bodies; MECMOD.Body PartBody = Bodis.Item(1); MECMOD.Body Body = Bodis.Add(); MECMOD.Sketches Skts = Body.Sketches; INFITF.Reference plane = (INFITF.Reference)Prt.OriginElements.PlaneXY; MECMOD.Sketch Skt = Skts.Add(plane); MECMOD.Factory2D Fac2D = Skt.OpenEdition(); Point2D Pt1 = Fac2D.CreatePoint(50, 50); Point2D Pt2 = Fac2D.CreatePoint(50, 100); Point2D Pt3 = Fac2D.CreatePoint(100, 100); Point2D Pt4 = Fac2D.CreatePoint(100, 50); // << Create Line >> Line2D Lin1 = Fac2D.CreateLine(50, 50, 50, 100); Line2D Lin2 = Fac2D.CreateLine(50, 100, 100, 100); Line2D Lin3 = Fac2D.CreateLine(100, 100, 100, 50); Line2D Lin4 = Fac2D.CreateLine(100, 50, 50, 50); // Line2D Lin22 = MCreateLine(Fac2d, Pt1, Pt2); //라인의 시작점부터 마지막점을 결정 Lin1.StartPoint = Pt1; Lin1.EndPoint = Pt2; Lin2.StartPoint = Pt2; Lin2.EndPoint = Pt3; Lin3.StartPoint = Pt3; Lin3.EndPoint = Pt4; Lin4.StartPoint = Pt4; Lin4.EndPoint = Pt1; INFITF.Reference rline1 = Prt.CreateReferenceFromGeometry(Lin1); INFITF.Reference rline2 = Prt.CreateReferenceFromGeometry(Lin2); INFITF.Reference rline3 = Prt.CreateReferenceFromGeometry(Lin3); INFITF.Reference rline4 = Prt.CreateReferenceFromGeometry(Lin4); INFITF.Reference rlineH = Prt.CreateReferenceFromGeometry(Skt.AbsoluteAxis.HorizontalReference); INFITF.Reference rlineV = Prt.CreateReferenceFromGeometry(Skt.AbsoluteAxis.VerticalReference); MECMOD.Constraint d1 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline1, rline3); MECMOD.Constraint d2 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline2, rline4); MECMOD.Constraint d3 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineH, rline4); MECMOD.Constraint d4 = Skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineV, rline1); Skt.CloseEdition();//Skech조건 끝 // //PAD를 하기 위해서 조건문을 만든다.// PARTITF.ShapeFactory ShpFac = (PARTITF.ShapeFactory)Prt.ShapeFactory; //그 shapeFactory를 돌출하기 위해서 AddNewPad를 사용해서 50만큼 돌출한다.// ShpFac.AddNewPad(Skt, 50); //새로운 Body2를 만들기 // MECMOD.Body Body2 = Bodis.Add(); //planed을 기준으로 Skt2를 만든다.// MECMOD.Sketch Skt2 = (MECMOD.Sketch)Body2.Sketches.Add(plane); //스켓이 시작 // Fac2D = Skt2.OpenEdition(); // X=75,Y=75 를 중심으로 D=20의 원을 만들기// Circle2D Cir2D = Fac2D.CreateClosedCircle(75, 75, 20); //스켓을 끝내기// Skt2.CloseEdition(); //PAD 80만큼 // ShpFac.AddNewPad(Skt2, 80); //Body3 만들기 // Body Body3 = Prt.Bodies.Add(); //Skt3를 Body2 안에 plane면을 기준으로 Sketche를 한다. Sketch Skt3 = Body2.Sketches.Add(plane); //스킷을 시작// Fac2D = Skt3.OpenEdition(); // X=75,Y=75 를 중심으로 D=5의 원을 만들기// Fac2D.CreateClosedCircle(75, 75, 5); //스켓3을 끝내기// Skt3.CloseEdition(); //스켓3을 80만큼 PAD를 한다. ShpFac.AddNewPad(Skt3, 80); ///////////////// //PartBody에 Prat In Work Object를 사용해서 조건을 만든다. Prt.InWorkObject = PartBody; ShpFac.AddNewAdd(Body); //PartBody에 Body를추가 ShpFac.AddNewAdd(Body2); //PartBody에 Body2를추가 ShpFac.AddNewRemove(Body3); //PartBody에 Body3를 제거한다 Prt.Update(); }
// CAT datei öffnen public void openFile() { hsp_catiaPart = (PartDocument)hsp_catiaApp.Documents.Open(@"C:\Users\Thomas\source\repos\Sprint3WPF\Sprint3WPF\bin\Debug\Tprofil.CATPart"); }