public bool ErzeugeBalkenRechteckrohr(Double tiefe, bool skizzeerstellt)
        {
            // Hauptkoerper in Bearbeitung definieren
            catiaPart.Part.InWorkObject = catiaPart.Part.MainBody;
            if (skizzeerstellt == true)
            {
                if (tiefe > 0)
                {
                    // Hauptkoerper in Bearbeitung definieren
                    catiaPart.Part.InWorkObject = catiaPart.Part.MainBody;

                    // Block(Balken) erzeugen
                    ShapeFactory catShapeFactory1 = (ShapeFactory)catiaPart.Part.ShapeFactory;
                    Pad          catPad1          = catShapeFactory1.AddNewPad(catiaSketch, tiefe);

                    // Block umbenennen
                    catPad1.set_Name("Balken");
                    // Block umbenennen
                    catPad1.set_Name("Balken");

                    // Part aktualisieren
                    catiaPart.Part.Update();
                    // Part aktualisieren
                    catiaPart.Part.Update();
                }
                else
                {
                    MessageBox.Show("Fehler beim Erzeugen des Körpers:\rDer Werte darf nicht null sein!");
                }
            }
            else
            {
                MessageBox.Show("Fehler beim Erzeugen des Körpers:\rEs konnte keine Skizze erstellt werden!");
            }
            return(skizzeerstellt);
        }
Example #2
0
        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();
        }
Example #3
0
        //InnenVerzahnung
        public void ErstelleProfilInnen(Data dat)
        {
            //geometrisches set auswählen und umbenennen
            HybridBodies catHybridBodies_I = hsp_catiaPart.Part.HybridBodies;
            HybridBody   catHybridBody_I;

            try
            {
                catHybridBody_I = catHybridBodies_I.Item("Geometrisches Set.1");
            }
            catch (Exception)
            {
                MessageBox.Show("Kein geometrisches Set gefunden!\nEin PART manuell erzeugen und darauf achten, dass ein 'Geometisches Set' aktiviert ist.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            catHybridBody_I.set_Name("Profile");

            //Neue Skizze im ausgewählten geometrischen Set anlegen
            Sketches       catSketches_I       = catHybridBody_I.HybridSketches;
            OriginElements catOriginElements_I = hsp_catiaPart.Part.OriginElements;
            Reference      catReference_I      = (Reference)catOriginElements_I.PlaneYZ;

            hsp_catiaProfil = catSketches_I.Add(catReference_I);

            //Achsensystem in Skizze erzeugen
            ErzeugeAchsensystem();

            //Part aktualisieren
            hsp_catiaPart.Part.Update();

            hsp_catiaProfil.set_Name("InnenverzahnungBlock");
            Factory2D catFactory_I = hsp_catiaProfil.OpenEdition();

            Circle2D catC2D_I = catFactory_I.CreateClosedCircle(0, 0, dat.getFußkreisdurchmesser_iZahnrad1());

            hsp_catiaProfil.CloseEdition();
            hsp_catiaPart.Part.Update();

            ShapeFactory       SF_I  = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;
            HybridShapeFactory HSF_I = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory;

            //Erzeuge Block aus Skizze
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;
            Pad myPad = SF_I.AddNewPad(hsp_catiaProfil, dat.getBreiteZahnrad1());

            hsp_catiaPart.Part.Update();



            //Neue Skizze im ausgewählten geometrischen Set anlegen
            Sketches       catSketches1      = catHybridBody_I.HybridSketches;
            OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements;
            Reference      catReference1     = (Reference)catOriginElements.PlaneYZ;

            hsp_catiaProfil = catSketches1.Add(catReference1);

            //Achsensystem in Skizze erzeugen
            ErzeugeAchsensystem();

            //Part aktualisieren
            hsp_catiaPart.Part.Update();


            //HilfsRadien
            double d_r  = (dat.getModulZahnrad1() * dat.getZaehnezahlZahnrad1()) / 2;
            double hk_r = d_r * 1.06;
            double da_r = d_r - (1.25 * dat.getModulZahnrad1());
            double df_r = d_r + dat.getModulZahnrad1();
            double vd_r = 0.35 * dat.getModulZahnrad1();

            //HilfsWinkel
            double alpha   = 20;
            double beta    = 90 / dat.getZaehnezahlZahnrad1();
            double beta_r  = Math.PI * beta / 180;
            double gamma   = 90 - (alpha - beta);
            double gamma_r = Math.PI * gamma / 180;
            double ta      = 360.0 / dat.getZaehnezahlZahnrad1();
            double ta_r    = Math.PI * ta / 180;

            //Nullpunkte
            double x0 = 0;
            double y0 = 0;

            //MittelPunkt EvolventenKreis
            double MP_EvolventenKreis_x = hk_r * Math.Cos(gamma_r);
            double MP_EvolventenKreis_y = hk_r * Math.Sin(gamma_r);

            // SchnittPunkt Evolventenkreis & Teilkreisradius
            double SP_EvolventenTeilKreis_x = -d_r *Math.Sin(beta_r);

            double SP_EvolventenTeilKreis_y = d_r * Math.Cos(beta_r);

            //Evolventenkreis Radius
            double Evolventenkreis_r = Math.Sqrt(Math.Pow((MP_EvolventenKreis_x - SP_EvolventenTeilKreis_x), 2) + Math.Pow((MP_EvolventenKreis_y - SP_EvolventenTeilKreis_y), 2));

            //SchnittPunkt Evolventenkreis & Kopfkreisradius
            double SP_EvolventenKopfKreis_x = Schnittpunkt_x(x0, y0, da_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r);
            double SP_EvolventenKopfKreis_y = Schnittpunkt_y(x0, y0, da_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r);

            //MittelPunkt VerrundungsRadius
            double MP_Verrundung_x = Schnittpunkt_x(x0, y0, df_r + vd_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r + vd_r);
            double MP_Verrundung_y = Schnittpunkt_y(x0, y0, df_r + vd_r, MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r + vd_r);

            //SchnittPunkt Evolventenkreis & Verrundungsradius
            double SP_EvolventeVerrundung_x = Schnittpunkt_x(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, MP_Verrundung_x, MP_Verrundung_y, vd_r);
            double SP_EvolventeVerrundung_y = Schnittpunkt_y(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, MP_Verrundung_x, MP_Verrundung_y, vd_r);

            //SchnittPunkt Fußkreis & Verrundungs Radius
            double SP_FußkreisVerrundungsRadius_x = Schnittpunkt_x(x0, y0, df_r, MP_Verrundung_x, MP_Verrundung_y, vd_r);
            double SP_FußkreisVerrundungsRadius_y = Schnittpunkt_y(x0, y0, df_r, MP_Verrundung_x, MP_Verrundung_y, vd_r);

            //StartPunkt Fußkreis Radius
            double phi = ta_r - Math.Atan(Math.Abs(SP_FußkreisVerrundungsRadius_x) / Math.Abs(SP_FußkreisVerrundungsRadius_y));
            double StartPkt_Fußkreis_x = -df_r *Math.Sin(phi);

            double StartPkt_Fußkreis_y = df_r * Math.Cos(phi);

            //Skizze umbenennen und öffnen
            hsp_catiaProfil.set_Name("InnenverzahnungEinzel");
            Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition();

            //Punkte
            Point2D catP2D_Ursprung = catFactory2D1.CreatePoint(x0, y0);

            Point2D catP2D_StartPkt_Fußkreis             = catFactory2D1.CreatePoint(StartPkt_Fußkreis_x, StartPkt_Fußkreis_y);
            Point2D catP2D_SP_FußkreisVerrundungsRadius1 = catFactory2D1.CreatePoint(SP_FußkreisVerrundungsRadius_x, SP_FußkreisVerrundungsRadius_y);
            Point2D catP2D_SP_FußkreisVerrundungsRadius2 = catFactory2D1.CreatePoint(-SP_FußkreisVerrundungsRadius_x, SP_FußkreisVerrundungsRadius_y);

            Point2D catP2D_MP_EvolventenKreis1 = catFactory2D1.CreatePoint(MP_EvolventenKreis_x, MP_EvolventenKreis_y);
            Point2D catP2D_MP_EvolventenKreis2 = catFactory2D1.CreatePoint(-MP_EvolventenKreis_x, MP_EvolventenKreis_y);

            Point2D catP2D_SP_EvolventenKopfKreis1 = catFactory2D1.CreatePoint(SP_EvolventenKopfKreis_x, SP_EvolventenKopfKreis_y);
            Point2D catP2D_SP_EvolventenKopfKreis2 = catFactory2D1.CreatePoint(-SP_EvolventenKopfKreis_x, SP_EvolventenKopfKreis_y);

            Point2D catP2D_MP_Verrundung1 = catFactory2D1.CreatePoint(MP_Verrundung_x, MP_Verrundung_y);
            Point2D catP2D_MP_Verrundung2 = catFactory2D1.CreatePoint(-MP_Verrundung_x, MP_Verrundung_y);

            Point2D catP2D_SP_EvolventeVerrundung1 = catFactory2D1.CreatePoint(SP_EvolventeVerrundung_x, SP_EvolventeVerrundung_y);
            Point2D catP2D_SP_EvolventeVerrundung2 = catFactory2D1.CreatePoint(-SP_EvolventeVerrundung_x, SP_EvolventeVerrundung_y);


            //Kreise
            Circle2D catC2D_Frußkreis = catFactory2D1.CreateCircle(x0, y0, df_r, 0, 0);

            catC2D_Frußkreis.CenterPoint = catP2D_Ursprung;
            catC2D_Frußkreis.StartPoint  = catP2D_SP_FußkreisVerrundungsRadius1;
            catC2D_Frußkreis.EndPoint    = catP2D_StartPkt_Fußkreis;

            Circle2D catC2D_Kopfkreis = catFactory2D1.CreateCircle(x0, y0, da_r, 0, 0);

            catC2D_Kopfkreis.CenterPoint = catP2D_Ursprung;
            catC2D_Kopfkreis.StartPoint  = catP2D_SP_EvolventenKopfKreis2;
            catC2D_Kopfkreis.EndPoint    = catP2D_SP_EvolventenKopfKreis1;

            Circle2D catC2D_EvolventenKreis1 = catFactory2D1.CreateCircle(MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, 0, 0);

            catC2D_EvolventenKreis1.CenterPoint = catP2D_MP_EvolventenKreis1;
            catC2D_EvolventenKreis1.StartPoint  = catP2D_SP_EvolventenKopfKreis1;
            catC2D_EvolventenKreis1.EndPoint    = catP2D_SP_EvolventeVerrundung1;

            Circle2D catC2D_Evolventenkreis2 = catFactory2D1.CreateCircle(-MP_EvolventenKreis_x, MP_EvolventenKreis_y, Evolventenkreis_r, 0, 0);

            catC2D_Evolventenkreis2.CenterPoint = catP2D_MP_EvolventenKreis2;
            catC2D_Evolventenkreis2.StartPoint  = catP2D_SP_EvolventeVerrundung2;
            catC2D_Evolventenkreis2.EndPoint    = catP2D_SP_EvolventenKopfKreis2;

            Circle2D catC2D_VerrundungsKreis1 = catFactory2D1.CreateCircle(MP_Verrundung_x, MP_Verrundung_y, vd_r, 0, 0);

            catC2D_VerrundungsKreis1.CenterPoint = catP2D_MP_Verrundung1;
            catC2D_VerrundungsKreis1.StartPoint  = catP2D_SP_FußkreisVerrundungsRadius1;
            catC2D_VerrundungsKreis1.EndPoint    = catP2D_SP_EvolventeVerrundung1;

            Circle2D catC2D_VerrundungsKreis2 = catFactory2D1.CreateCircle(-MP_Verrundung_x, MP_Verrundung_y, vd_r, 0, 0);

            catC2D_VerrundungsKreis2.CenterPoint = catP2D_MP_Verrundung2;
            catC2D_VerrundungsKreis2.StartPoint  = catP2D_SP_EvolventeVerrundung2;
            catC2D_VerrundungsKreis2.EndPoint    = catP2D_SP_FußkreisVerrundungsRadius2;

            hsp_catiaProfil.CloseEdition();

            hsp_catiaPart.Part.Update();

            //Skizze und Referenzen
            Factory2D Factory2D1 = hsp_catiaProfil.Factory2D;

            HybridShapePointCoord Ursprung    = HSF_I.AddNewPointCoord(0, 0, 0);
            Reference             RefUrsprung = hsp_catiaPart.Part.CreateReferenceFromObject(Ursprung);
            HybridShapeDirection  XDir        = HSF_I.AddNewDirectionByCoord(1, 0, 0);
            Reference             RefXDir     = hsp_catiaPart.Part.CreateReferenceFromObject(XDir);

            //Kreismuster mit Daten füllen
            CircPattern Kreismuster = SF_I.AddNewSurfacicCircPattern(Factory2D1, 1, 2, 0, 0, 1, 1, RefUrsprung, RefXDir, false, 0, true, false);

            Kreismuster.CircularPatternParameters = CatCircularPatternParameters.catInstancesandAngularSpacing;
            AngularRepartition angularRepartition1 = Kreismuster.AngularRepartition;
            Angle angle1 = angularRepartition1.AngularSpacing;

            angle1.Value = Convert.ToDouble(360 / dat.getZaehnezahlZahnrad1());
            AngularRepartition angularRepartition2 = Kreismuster.AngularRepartition;
            IntParam           intParam1           = angularRepartition2.InstancesCount;

            intParam1.Value = Convert.ToInt32(dat.getZaehnezahlZahnrad1()) + 1;

            //geschlossene Kontur
            Reference           Ref_Kreismuster = hsp_catiaPart.Part.CreateReferenceFromObject(Kreismuster);
            HybridShapeAssemble Verbindung      = HSF_I.AddNewJoin(Ref_Kreismuster, Ref_Kreismuster);
            Reference           Ref_Verbindung  = hsp_catiaPart.Part.CreateReferenceFromObject(Verbindung);

            HSF_I.GSMVisibility(Ref_Verbindung, 0);

            hsp_catiaPart.Part.Update();

            /*Bodies bodies = hsp_catiaPart.Part.Bodies;
             * Body myBody = bodies.Add();
             * myBody.set_Name("Zahnrad");
             * myBody.InsertHybridShape(Verbindung);
             *
             * hsp_catiaPart.Part.Update();*/

            //Tasche für Innenverzahnung(grob)
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;

            Pocket catPocketInnen = SF_I.AddNewPocketFromRef(Ref_Verbindung, dat.getBreiteZahnrad1());

            hsp_catiaPart.Part.Update();
        }
        public void SonderT_Extrusion(double SonderT_Laenge, double SonderT_Flanschbreite, double SonderT_Stegbreite)
        {
            double l = SonderT_Laenge;
            double f = SonderT_Flanschbreite;
            double s = SonderT_Stegbreite;

            double R1 = f;
            double R2 = s / 2;
            double R3 = s / 4;

            CATIA_SonderT_Part.Part.InWorkObject = CATIA_SonderT_Part.Part.MainBody;

            ShapeFactory SonderT_3D  = (ShapeFactory)CATIA_SonderT_Part.Part.ShapeFactory;
            Pad          SonderT_Pad = SonderT_3D.AddNewPad(CATIA_SonderT_2D, l);

            // Kantenverrundung #1 für R1
            Reference          Referenz11_R1  = CATIA_SonderT_Part.Part.CreateReferenceFromName("");
            ConstRadEdgeFillet Verrundung1_R1 = SonderT_3D.AddNewEdgeFilletWithConstantRadius(Referenz11_R1, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R1);
            Reference          Referenz21_R1  = CATIA_SonderT_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;6)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;5)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderT_Pad);

            Verrundung1_R1.AddObjectToFillet(Referenz21_R1);
            Verrundung1_R1.set_Name("Verrundung1_R1 = " + R1);

            // Kantenverrundung #2 für R1
            Reference          Referenz12_R1  = CATIA_SonderT_Part.Part.CreateReferenceFromName("");
            ConstRadEdgeFillet Verrundung2_R1 = SonderT_3D.AddNewEdgeFilletWithConstantRadius(Referenz12_R1, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R1);
            Reference          Referenz22_R1  = CATIA_SonderT_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;2)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderT_Pad);

            Verrundung2_R1.AddObjectToFillet(Referenz22_R1);
            Verrundung2_R1.set_Name("Verrundung2_R1 = " + R1);

            // Kantenverrundung #1 für R2
            Reference          Referenz11_R2  = CATIA_SonderT_Part.Part.CreateReferenceFromName("");
            ConstRadEdgeFillet Verrundung1_R2 = SonderT_3D.AddNewEdgeFilletWithConstantRadius(Referenz11_R2, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R2);
            Reference          Referenz21_R2  = CATIA_SonderT_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;7)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;6)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderT_Pad);

            Verrundung1_R2.AddObjectToFillet(Referenz21_R2);
            Verrundung1_R2.set_Name("Verrundung1_R2 = " + R2);

            // Kantenverrundung #2 für R2
            Reference          Referenz12_R2  = CATIA_SonderT_Part.Part.CreateReferenceFromName("");
            ConstRadEdgeFillet Verrundung2_R2 = SonderT_3D.AddNewEdgeFilletWithConstantRadius(Referenz12_R2, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R2);
            Reference          Referenz22_R2  = CATIA_SonderT_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;2)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;1)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderT_Pad);

            Verrundung2_R2.AddObjectToFillet(Referenz22_R2);
            Verrundung2_R2.set_Name("Verrundung2_R2 = " + R2);

            // Kantenverrundung #1 für R3
            Reference          Referenz11_R3  = CATIA_SonderT_Part.Part.CreateReferenceFromName("");
            ConstRadEdgeFillet Verrundung1_R3 = SonderT_3D.AddNewEdgeFilletWithConstantRadius(Referenz11_R3, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R3);
            Reference          Referenz21_R3  = CATIA_SonderT_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;5)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;4)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderT_Pad);

            Verrundung1_R3.AddObjectToFillet(Referenz21_R3);
            Verrundung1_R3.set_Name("Verrundung1_R3 = " + R3);

            // Kantenverrundung #2 für R3
            Reference          Referenz12_R3  = CATIA_SonderT_Part.Part.CreateReferenceFromName("");
            ConstRadEdgeFillet Verrundung2_R3 = SonderT_3D.AddNewEdgeFilletWithConstantRadius(Referenz12_R3, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, R3);
            Reference          Referenz22_R3  = CATIA_SonderT_Part.Part.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;4)));None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SonderT_Pad);

            Verrundung2_R3.AddObjectToFillet(Referenz22_R3);
            Verrundung2_R3.set_Name("Verrundung2_R3 = " + R3);

            SonderT_Pad.set_Name("T-Traeger");

            CATIA_SonderT_Part.Part.Update();
        }
Example #5
0
        public void ErzeugeBalken(double l)
        {
            //Hauptkörper in Bearbeitung
            catiaPart.Part.InWorkObject = catiaPart.Part.MainBody;
            ShapeFactory shapeFac = (ShapeFactory)catiaPart.Part.ShapeFactory;


            //BLOCK
            Pad newPad = shapeFac.AddNewPad(catiaProfil, l);

            newPad.set_Name("Block");



            catiaPart.Part.Update();



            //FASE

            Reference reference1 = catiaPart.Part.CreateReferenceFromName("");

            Chamfer chamfer = shapeFac.AddNewChamfer(
                reference1,
                CatChamferPropagation.catTangencyChamfer,
                CatChamferMode.catLengthAngleChamfer,
                CatChamferOrientation.catNoReverseChamfer,
                1,
                45);

            Reference reference2 = catiaPart.Part.CreateReferenceFromBRepName("RSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", newPad);

            /*("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());Face:(Brp:(Pad.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1);*/

            //"RSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1)

            chamfer.AddElementToChamfer(reference2);
            chamfer.Mode        = CatChamferMode.catLengthAngleChamfer;
            chamfer.Propagation = CatChamferPropagation.catTangencyChamfer;
            chamfer.Orientation = CatChamferOrientation.catNoReverseChamfer;

            catiaPart.Part.Update();


            Reference reference3 = catiaPart.Part.CreateReferenceFromName("");

            Chamfer chamfer2 = shapeFac.AddNewChamfer(
                reference3,
                CatChamferPropagation.catTangencyChamfer,
                CatChamferMode.catLengthAngleChamfer,
                CatChamferOrientation.catNoReverseChamfer,
                1,
                45);

            Reference reference4 = catiaPart.Part.CreateReferenceFromBRepName("RSur:(Face:(Brp:(Pad.1;1);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", newPad);

            /*("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());Face:(Brp:(Pad.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1);*/

            //"RSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1)
            chamfer2.AddElementToChamfer(reference4);
            chamfer2.Mode        = CatChamferMode.catLengthAngleChamfer;
            chamfer2.Propagation = CatChamferPropagation.catTangencyChamfer;
            chamfer2.Orientation = CatChamferOrientation.catNoReverseChamfer;


            catiaPart.Part.Update();
        }
Example #6
0
        //Innenverzahntes Stirnrad
        public void ErzeugeProfilInnen(Data dat)
        {
            //KOORDINATEN ANLEGEN
            //Nullpunkt
            double x0 = 0;
            double y0 = 0;

            //Radien und Winkel umgestellt
            double Teilkreisradius = dat.getTeilkreisdurchmesser() / 2;
            //Angenährt
            double Hilfskreisradius  = Teilkreisradius * 1.12;
            double Kopfkreisradius   = Teilkreisradius - (1.25 * dat.getModul());
            double Fußkreisradius    = Teilkreisradius + dat.getModul();
            double Verrundungsradius = 0.35 * dat.getModul();

            double Alpha         = 20;
            double Beta          = 90 / dat.getZähnezahl();
            double Betarad       = Math.PI * Beta / 180;
            double Gamma         = 90 - (Alpha - Beta);
            double Gammarad      = Math.PI * Gamma / 180;
            double Totalangel    = 360.0 / dat.getZähnezahl();
            double Totalangelrad = Math.PI * Totalangel / 180;

            //Schnittpunkte und Koordinaten
            //Evolventenkreis Center Koordinaten
            double xMittelpunktaufEvol_links = Hilfskreisradius * Math.Cos(Gammarad);
            double yMittelpunktaufEvol_links = Hilfskreisradius * Math.Sin(Gammarad);

            //Schnittpkt. der Evolvente und dem Teilkreisradius
            double xPunktAufEvolvente = -Teilkreisradius *Math.Sin(Betarad);

            double yPunktAufEvolvente = Teilkreisradius * Math.Cos(Betarad);

            //Evolvente Radius
            double EvolventenkreisRadius = Math.Sqrt(Math.Pow((xMittelpunktaufEvol_links - xPunktAufEvolvente), 2) + Math.Pow((yMittelpunktaufEvol_links - yPunktAufEvolvente), 2));

            //Schnittpunkt Kopfkreis und Evolventenkreis
            double xEvolventenkopfkreis_links = Schnittpunkt_X(x0, y0, Kopfkreisradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius);
            double yEvolventenkopfkreis_links = Schnittpunkt_Y(x0, y0, Kopfkreisradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius);

            //Center Verrundung
            double xMittelpunktVerrundung_links = Schnittpunkt_X(x0, y0, Fußkreisradius - Verrundungsradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius + Verrundungsradius);
            double yMittelpunktVerrundung_links = Schnittpunkt_Y(x0, y0, Fußkreisradius - Verrundungsradius, xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius + Verrundungsradius);

            //Schnittpunkt Verrundung Evolventenkreis
            double x_SP_EvolventeVerrundung_links = Schnittpunkt_X(xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius);
            double y_SP_EvolventeVerrundung_links = Schnittpunkt_Y(xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius);

            //Schnittpunkt Verrundung Fußkreis
            double x_SP_FußkreisradiusVerrundung_links = Schnittpunkt_X(x0, y0, Fußkreisradius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius);
            double y_SP_FußkreisradiusVerrundung_links = Schnittpunkt_Y(x0, y0, Fußkreisradius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius);

            //Anfangspunkt Fußkreis
            double Hilfswinkel            = Totalangelrad - Math.Atan(Math.Abs(x_SP_FußkreisradiusVerrundung_links) / Math.Abs(y_SP_FußkreisradiusVerrundung_links));
            double x_AnfangspunktFußkreis = -Fußkreisradius *Math.Sin(Hilfswinkel);

            double y_AnfangspunktFußkreis = Fußkreisradius * Math.Cos(Hilfswinkel);



            //Geometrisches Set auswählen und umbennen
            HybridBodies catHybridBodies1 = hsp_catiaPart.Part.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");



            //ERSTELLE SKIZZE FÜR SCHEIBE
            Sketches       sketchesBohrung   = catHybridBody1.HybridSketches;
            OriginElements catoriginelements = hsp_catiaPart.Part.OriginElements;
            Reference      refmxPlaneX       = (Reference)catoriginelements.PlaneYZ;

            hsp_catiaProfil = sketchesBohrung.Add(refmxPlaneX);

            ErzeugeAchsensystem();

            hsp_catiaPart.Part.Update();


            //Skizze umbenennen und öffnen
            hsp_catiaProfil.set_Name("Scheibe");
            Factory2D catfactory2D2 = hsp_catiaProfil.OpenEdition();

            //Kreis
            Circle2D Scheibe = catfactory2D2.CreateClosedCircle(x0, y0, dat.getAußenradius());

            //Skizze schließen
            hsp_catiaProfil.CloseEdition();

            //Update
            hsp_catiaPart.Part.Update();

            //Erzeuge Block
            ShapeFactory shapeFactoryScheibe = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;

            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;
            Pad Block = shapeFactoryScheibe.AddNewPad(hsp_catiaProfil, dat.getBreite());

            hsp_catiaPart.Part.Update();



            //Zahnradskizze erstellen

            //Skizze umbenennen und öffnen
            Sketches       catSketches1      = catHybridBody1.HybridSketches;
            OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements;
            Reference      catReference1     = (Reference)catOriginElements.PlaneYZ;

            hsp_catiaProfil = catSketches1.Add(catReference1);

            //Achsensystem in Skizze erstellen
            ErzeugeAchsensystem();

            //Update
            hsp_catiaPart.Part.Update();

            //Umbennen und öffnen
            hsp_catiaProfil.set_Name("Innenverzahntes Stirnrad");
            Factory2D catfactory2D1 = hsp_catiaProfil.OpenEdition();

            //Punkte in Skizze einzeichnen
            Point2D point_Ursprung                   = catfactory2D1.CreatePoint(x0, y0);
            Point2D pointAnfangFußkreisLinks         = catfactory2D1.CreatePoint(x_AnfangspunktFußkreis, y_AnfangspunktFußkreis);
            Point2D pointFußkreisVerrundungLinks     = catfactory2D1.CreatePoint(x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links);
            Point2D pointFußkreisVerrundungRechts    = catfactory2D1.CreatePoint(-x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links);
            Point2D pointMittelpunktVerrundungLinks  = catfactory2D1.CreatePoint(xMittelpunktVerrundung_links, yMittelpunktVerrundung_links);
            Point2D pointMittelpunktVerrundungRechts = catfactory2D1.CreatePoint(-xMittelpunktVerrundung_links, yMittelpunktVerrundung_links);
            Point2D pointVerrundungEvolventeLinks    = catfactory2D1.CreatePoint(x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links);
            Point2D pointVerrundungEvolventeRechts   = catfactory2D1.CreatePoint(-x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links);
            Point2D pointMittelpunktevolventeLinks   = catfactory2D1.CreatePoint(xMittelpunktaufEvol_links, yMittelpunktaufEvol_links);
            Point2D pointMittelpunktevolventeRechts  = catfactory2D1.CreatePoint(-xMittelpunktaufEvol_links, yMittelpunktaufEvol_links);
            Point2D pointEvolventenKopfkreisLinks    = catfactory2D1.CreatePoint(xEvolventenkopfkreis_links, yEvolventenkopfkreis_links);
            Point2D pointEvolventenKopfkreisRechts   = catfactory2D1.CreatePoint(-xEvolventenkopfkreis_links, yEvolventenkopfkreis_links);

            //Kreise einzeichnen
            Circle2D KreisFrußkreis = catfactory2D1.CreateCircle(x0, y0, Fußkreisradius, 0, Math.PI * 2);

            KreisFrußkreis.CenterPoint = point_Ursprung;
            KreisFrußkreis.StartPoint  = pointFußkreisVerrundungLinks;
            KreisFrußkreis.EndPoint    = pointAnfangFußkreisLinks;

            Circle2D KreisVerrundungLinks = catfactory2D1.CreateCircle(xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius, 0, Math.PI * 2);

            KreisVerrundungLinks.CenterPoint = pointMittelpunktVerrundungLinks;
            KreisVerrundungLinks.EndPoint    = pointFußkreisVerrundungLinks;
            KreisVerrundungLinks.StartPoint  = pointVerrundungEvolventeLinks;

            Circle2D KreisEvolventenkreisLinks = catfactory2D1.CreateCircle(xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, 0, Math.PI * 2);

            KreisEvolventenkreisLinks.CenterPoint = pointMittelpunktevolventeLinks;
            KreisEvolventenkreisLinks.EndPoint    = pointEvolventenKopfkreisLinks;
            KreisEvolventenkreisLinks.StartPoint  = pointVerrundungEvolventeLinks;

            Circle2D KreisKopfkreis = catfactory2D1.CreateCircle(x0, y0, Kopfkreisradius, 0, Math.PI * 2);

            KreisKopfkreis.CenterPoint = point_Ursprung;
            KreisKopfkreis.StartPoint  = pointEvolventenKopfkreisRechts;
            KreisKopfkreis.EndPoint    = pointEvolventenKopfkreisLinks;

            Circle2D KreisEvolventenkreisRechts = catfactory2D1.CreateCircle(-xMittelpunktaufEvol_links, yMittelpunktaufEvol_links, EvolventenkreisRadius, 0, Math.PI * 2);

            KreisEvolventenkreisRechts.CenterPoint = pointMittelpunktevolventeRechts;
            KreisEvolventenkreisRechts.EndPoint    = pointVerrundungEvolventeRechts;
            KreisEvolventenkreisRechts.StartPoint  = pointEvolventenKopfkreisRechts;

            Circle2D KreisVerrundungRechts = catfactory2D1.CreateCircle(-xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius, 0, Math.PI * 2);

            KreisVerrundungRechts.CenterPoint = pointMittelpunktVerrundungRechts;
            KreisVerrundungRechts.EndPoint    = pointVerrundungEvolventeRechts;
            KreisVerrundungRechts.StartPoint  = pointFußkreisVerrundungRechts;


            //Schließen
            hsp_catiaProfil.CloseEdition();

            //Updaten
            hsp_catiaPart.Part.Update();



            //ERSTELLE KREISMUSTER
            HybridShapeFactory hybridShapeFactory1 = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory;
            ShapeFactory       shapeFactory1       = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;

            Factory2D factory2D1 = hsp_catiaProfil.Factory2D;

            HybridShapePointCoord ursprung    = hybridShapeFactory1.AddNewPointCoord(0, 0, 0);
            Reference             refUrsprung = hsp_catiaPart.Part.CreateReferenceFromObject(ursprung);

            HybridShapeDirection xRichtung    = hybridShapeFactory1.AddNewDirectionByCoord(1, 0, 0);
            Reference            refxRichtung = hsp_catiaPart.Part.CreateReferenceFromObject(xRichtung);

            CircPattern kreismuster = shapeFactory1.AddNewSurfacicCircPattern(factory2D1, 1, 2, 0, 0, 1, 1, refUrsprung, refxRichtung, false, 0, true, false);

            kreismuster.CircularPatternParameters = CatCircularPatternParameters.catInstancesandAngularSpacing;
            AngularRepartition angularRepartition1 = kreismuster.AngularRepartition;
            Angle angle1 = angularRepartition1.AngularSpacing;

            angle1.Value = Convert.ToDouble(360 / dat.getZähnezahl());
            AngularRepartition angularRepartition2 = kreismuster.AngularRepartition;
            IntParam           intParam1           = angularRepartition2.InstancesCount;

            intParam1.Value = Convert.ToInt32(dat.getZähnezahl()) + 1;


            //Kreismusterenden verbinden

            Reference           refKreismuster = hsp_catiaPart.Part.CreateReferenceFromObject(kreismuster);
            HybridShapeAssemble verbindung     = hybridShapeFactory1.AddNewJoin(refKreismuster, refKreismuster);
            Reference           refVerbindung  = hsp_catiaPart.Part.CreateReferenceFromObject(verbindung);

            hybridShapeFactory1.GSMVisibility(refVerbindung, 0);

            hsp_catiaPart.Part.MainBody.InsertHybridShape(verbindung);


            //Update
            hsp_catiaPart.Part.Update();

            //Tasche
            ErzeugeTasche(dat, refVerbindung, shapeFactory1);
            hsp_catiaProfil = catSketches1.Parent as MECMOD.Sketch;
            hsp_catiaPart.Part.Update();
        }
Example #7
0
        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;
            Bodies       bdys     = prt.Bodies;
            Body         PartBody = bdys.Item(1);

            INFITF.Reference xypln  = (INFITF.Reference)prt.OriginElements.PlaneXY; //다른 body에서 사용가능
            ShapeFactory     shpfac = (ShapeFactory)prt.ShapeFactory;

            //1 body1생성-----------------------
            Body      bdy1  = bdys.Add();
            Sketches  skts  = bdy1.Sketches;
            Sketch    skt   = skts.Add(xypln);
            Factory2D fac2d = skt.OpenEdition();

            CreateRectangle(fac2d, prt, skt, 50, 50, 100, 100); //사각형을 만든 method를 작성했다

            skt.CloseEdition();

            Pad p1 = shpfac.AddNewPad(skt, 80);

            //2--------------------------------
            Body   bdy2 = bdys.Add();
            Sketch skt2 = bdy2.Sketches.Add(xypln);

            fac2d = skt2.OpenEdition();

            Circle2D c = fac2d.CreateClosedCircle(75, 75, 20);

            skt2.CloseEdition();
            Pad p2 = shpfac.AddNewPad(skt2, 100);

            //3----------------------------------
            Body   bdy3 = bdys.Add();
            Sketch skt3 = bdy3.Sketches.Add(xypln);

            fac2d = skt3.OpenEdition();

            Point2D pt1 = fac2d.CreatePoint(75, 80);
            Point2D pt2 = fac2d.CreatePoint(70, 70);
            Point2D pt3 = fac2d.CreatePoint(80, 70);

            CreateTriangle(fac2d, prt, skt3, pt1, pt2, pt3);        //삼각형을 만든 method를 작성했다

            skt3.CloseEdition();
            Pad p3 = shpfac.AddNewPad(skt3, 100);

            //----------------------------------------------
            prt.InWorkObject = PartBody;        //workobject 지정한다

            shpfac.AddNewAdd(bdy1);
            shpfac.AddNewAdd(bdy2);
            shpfac.AddNewRemove(bdy3);

            prt.Update();
        }
Example #8
0
        public void ZylinderkopfInnensechskant(MetrischeGewindegroesse m)
        {
            #region SKizze bauen
            // neue Skizze im ausgewaehlten geometrischen Set anlegen
            Sketches       catSketches1      = catHybridBody1.HybridSketches;
            OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements;
            Reference      catReference1     = (Reference)catOriginElements.PlaneYZ;
            hsp_catiaProfil = catSketches1.Add(catReference1);

            // Achsensystem in Skizze erstellen
            ErzeugeAchsensystem();
            hsp_catiaProfil.set_Name("Zylinderkopf mit Innensechskannt");
            // Skizzierer verlassen
            hsp_catiaProfil.CloseEdition();
            // Part aktualisieren
            hsp_catiaPart.Part.Update();

            Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition();

            // erst die Punkte
            Point2D catPoint2D1 = catFactory2D1.CreatePoint(0, 0);

            // dann den Kreis
            Circle2D catCircle2D_1 = catFactory2D1.CreateCircle(0, 0, m.kopfdurchmesser / 2, 0, 0);
            catCircle2D_1.CenterPoint = catPoint2D1;

            // Skizzierer verlassen
            hsp_catiaProfil.CloseEdition();

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion

            #region Pad
            // Hauptkoerper in Bearbeitung definieren
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;

            // Block(Schaft) erzeugen
            ShapeFactory catShapeFactory1 = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;
            KopfPad = catShapeFactory1.AddNewPad(hsp_catiaProfil, -m.mutterhoehe);

            // Block umbenennen
            KopfPad.set_Name("Kopf");

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion

            #region Offsetebene
            Reference RefmyPlaneYZ = (Reference)catOriginElements.PlaneYZ;
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part;
            HybridShapeFactory     hybridShapeFactory1 = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory;
            HybridShapePlaneOffset OffsetEbene         = hybridShapeFactory1.AddNewPlaneOffset(RefmyPlaneYZ, m.mutterhoehe, true);
            OffsetEbene.set_Name("OffsetEbene");
            Reference    RefOffsetEbene = hsp_catiaPart.Part.CreateReferenceFromObject(OffsetEbene);
            HybridBodies hybridBodies1  = hsp_catiaPart.Part.HybridBodies;
            HybridBody   hybridBody1    = hybridBodies1.Item("Profile");
            hybridBody1.AppendHybridShape(OffsetEbene);


            hsp_catiaPart.Part.Update();
            Sketches catSketches2    = catHybridBody1.HybridSketches;
            Sketch   SkizzeaufOffset = catSketches2.Add(RefOffsetEbene);
            hsp_catiaPart.Part.InWorkObject = SkizzeaufOffset;
            SkizzeaufOffset.set_Name("OffsetSkizze");

            // Achsensystem in Skizze erstellen
            ErzeugeAchsensystem();
            // Skizzierer verlassen
            SkizzeaufOffset.CloseEdition();
            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion

            #region Innensechskannt
            Factory2D catFactory2D2 = SkizzeaufOffset.OpenEdition();

            // Sechskant erzeugen
            double tan30 = Math.Sqrt(3) / 3;
            double cos30 = Math.Sqrt(3) / 2;
            double mSW   = m.innensechskant / 2;

            // erst die Punkte
            Point2D catPoint2D2 = catFactory2D2.CreatePoint(mSW, tan30 * mSW);
            Point2D catPoint2D3 = catFactory2D2.CreatePoint(mSW, -(tan30 * mSW));
            Point2D catPoint2D4 = catFactory2D2.CreatePoint(0, -(mSW / cos30));
            Point2D catPoint2D5 = catFactory2D2.CreatePoint(-mSW, -(tan30 * mSW));
            Point2D catPoint2D6 = catFactory2D2.CreatePoint(-mSW, tan30 * mSW);
            Point2D catPoint2D7 = catFactory2D2.CreatePoint(0, mSW / cos30);

            // dann die Linien
            Line2D catLine2D1 = catFactory2D2.CreateLine(mSW, tan30 * mSW, mSW, -(tan30 * mSW));
            catLine2D1.StartPoint = catPoint2D2;
            catLine2D1.EndPoint   = catPoint2D3;

            Line2D catLine2D2 = catFactory2D2.CreateLine(mSW, -(tan30 * mSW), 0, -(mSW / cos30));
            catLine2D2.StartPoint = catPoint2D3;
            catLine2D2.EndPoint   = catPoint2D4;

            Line2D catLine2D3 = catFactory2D2.CreateLine(0, -(mSW / cos30), -mSW, -(tan30 * mSW));
            catLine2D3.StartPoint = catPoint2D4;
            catLine2D3.EndPoint   = catPoint2D5;

            Line2D catLine2D4 = catFactory2D2.CreateLine(-mSW, -(tan30 * mSW), -mSW, (tan30 * mSW));
            catLine2D4.StartPoint = catPoint2D5;
            catLine2D4.EndPoint   = catPoint2D6;

            Line2D catLine2D5 = catFactory2D2.CreateLine(-mSW, (tan30 * mSW), 0, mSW / cos30);
            catLine2D5.StartPoint = catPoint2D6;
            catLine2D5.EndPoint   = catPoint2D7;

            Line2D catLine2D6 = catFactory2D2.CreateLine(0, mSW / cos30, mSW, tan30 * mSW);
            catLine2D6.StartPoint = catPoint2D7;
            catLine2D6.EndPoint   = catPoint2D2;

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion

            #region Verrundung
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;

            ShapeFactory catshapeFactoryRadius = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;

            Reference reference1 = hsp_catiaPart.Part.CreateReferenceFromBRepName(  //Hier scheint der Fehler drin zu stecken, er erkennt nicht die richtige kante--wenn nicht die Kante, sondern die Fläche ausgewählt wird, scheint der Fehler behpoben zu sein
                "RSur:(Face:(Brp:(Pad.2;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", KopfPad);
            // "REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;1)));None:();Cf11:());Face:(Brp:(Pad.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SchaftPad);
            RadiusKopf = catshapeFactoryRadius.AddNewEdgeFilletWithConstantRadius(reference1, CatFilletEdgePropagation.catTangencyFilletEdgePropagation, m.fase);


            RadiusKopf.set_Name("Radius");
            hsp_catiaPart.Part.Update();
            #endregion

            #region Tasche Innensechskannt
            // Hauptkoerper in Bearbeitung definieren
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;

            // Tasche erzeugen erzeugen
            ShapeFactory catShapeFactory2 = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;

            SchlitzPocket = catShapeFactory2.AddNewPocket(SkizzeaufOffset, -m.innensktiefe);

            // Block umbenennen
            SchlitzPocket.set_Name("Innensechskant");

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion
        }
Example #9
0
        public void Sechskant(MetrischeGewindegroesse m)
        {
            #region SKizze bauen
            // neue Skizze im ausgewaehlten geometrischen Set anlegen
            Sketches       catSketches1      = catHybridBody1.HybridSketches;
            OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements;
            Reference      catReference1     = (Reference)catOriginElements.PlaneYZ;
            hsp_catiaProfil = catSketches1.Add(catReference1);

            // Achsensystem in Skizze erstellen
            ErzeugeAchsensystem();
            hsp_catiaProfil.set_Name("Sechskantkopf");
            // Skizzierer verlassen
            hsp_catiaProfil.CloseEdition();
            // Part aktualisieren
            hsp_catiaPart.Part.Update();


            Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition();

            // Sechskant erzeugen
            double tan30 = Math.Sqrt(3) / 3;
            double cos30 = Math.Sqrt(3) / 2;
            double mSW   = m.schluesselweite / 2;
            //double mSW = 16;                              //Test mit Schlüsselweite 16

            // erst die Punkte
            Point2D catPoint2D1 = catFactory2D1.CreatePoint(mSW, tan30 * mSW);
            Point2D catPoint2D2 = catFactory2D1.CreatePoint(mSW, -(tan30 * mSW));
            Point2D catPoint2D3 = catFactory2D1.CreatePoint(0, -(mSW / cos30));
            Point2D catPoint2D4 = catFactory2D1.CreatePoint(-mSW, -(tan30 * mSW));
            Point2D catPoint2D5 = catFactory2D1.CreatePoint(-mSW, tan30 * mSW);
            Point2D catPoint2D6 = catFactory2D1.CreatePoint(0, mSW / cos30);

            // dann die Linien
            Line2D catLine2D1 = catFactory2D1.CreateLine(mSW, tan30 * mSW, mSW, -(tan30 * mSW));
            catLine2D1.StartPoint = catPoint2D1;
            catLine2D1.EndPoint   = catPoint2D2;

            Line2D catLine2D2 = catFactory2D1.CreateLine(mSW, -(tan30 * mSW), 0, -(mSW / cos30));
            catLine2D2.StartPoint = catPoint2D2;
            catLine2D2.EndPoint   = catPoint2D3;

            Line2D catLine2D3 = catFactory2D1.CreateLine(0, -(mSW / cos30), -mSW, -(tan30 * mSW));
            catLine2D3.StartPoint = catPoint2D3;
            catLine2D3.EndPoint   = catPoint2D4;

            Line2D catLine2D4 = catFactory2D1.CreateLine(-mSW, -(tan30 * mSW), -mSW, (tan30 * mSW));
            catLine2D4.StartPoint = catPoint2D4;
            catLine2D4.EndPoint   = catPoint2D5;

            Line2D catLine2D5 = catFactory2D1.CreateLine(-mSW, (tan30 * mSW), 0, mSW / cos30);
            catLine2D5.StartPoint = catPoint2D5;
            catLine2D5.EndPoint   = catPoint2D6;

            Line2D catLine2D6 = catFactory2D1.CreateLine(0, mSW / cos30, mSW, tan30 * mSW);
            catLine2D6.StartPoint = catPoint2D6;
            catLine2D6.EndPoint   = catPoint2D1;

            // Part aktualisieren
            hsp_catiaPart.Part.Update();

            #endregion

            #region Pad
            // Hauptkoerper in Bearbeitung definieren
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;

            // Block(Balken) erzeugen
            ShapeFactory catShapeFactory2 = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;

            KopfPad = catShapeFactory2.AddNewPad(hsp_catiaProfil, -m.kopfhoehesechs);
            //Pad catPad2 = catShapeFactory2.AddNewPad(hsp_catiaProfil, -12);                   // Test mit Mutterhoehe 12

            // Block umbenennen
            KopfPad.set_Name("Kopf");

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion

            Sechskantverrundung(m);
        }