Пример #1
0
        internal void SkizzeZylinderErstellen()
        {
            shapefac = (ShapeFactory)hsp_catiaPartDoc.Part.ShapeFactory;
            HybridBodies catHybridbodys1 = hsp_catiaPartDoc.Part.HybridBodies;
            HybridBody   catHybridBody1;

            try
            {
                // "Abfangen" des geometrischen Sets
                catHybridBody1 = catHybridbodys1.Item("Geometrisches Set.1");
            }
            catch (Exception)
            {
                /* MessageBox.Show("Kein Geometrisches Set gefunden", "Fehler");MessageBoxButton.OK, MessageBoxImage.Error);
                 */return;
            }
            //Geometrisches Set Benennen
            catHybridBody1.set_Name("Schraube Außensechskannt");

            //Typ Skizzen definieren
            sketches_Schraube = catHybridBody1.HybridSketches;

            // Referenz für die Skizze festlgen
            OriginElements catoriginElements = hsp_catiaPartDoc.Part.OriginElements;
            Reference      catRef1           = (Reference)catoriginElements.PlaneYZ;

            //Skizze in YZ Ebene hizufügen
            hsp_catiaSkizze = sketches_Schraube.Add(catRef1);

            ErzeugeAchsensystem();

            hsp_catiaPartDoc.Part.Update();
        }
Пример #2
0
        public void ErstelleLeereSkizze()
        {
            // geometrisches Set auswaehlen und umbenennen
            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");
            // 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();

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
        }
Пример #3
0
        public void ErstelleLeereSkizze()
        {
            HybridBody   catHybridBody1;
            HybridBodies catHybridBodies1;

            try
            {
                catHybridBodies1 = hsp_catiaPart.Part.HybridBodies;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Was auch immer");
                return;
            }

            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");
            Sketches       catSketches1      = catHybridBody1.HybridSketches;
            OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements;
            Reference      catReference1     = (Reference)catOriginElements.PlaneYZ;

            hsp_catiaProfil = catSketches1.Add(catReference1);
            ErzeugeAchsensystem();
            hsp_catiaPart.Part.Update();
        }
Пример #4
0
        public void Kreis_hohl_CreateSketch()
        {
            HybridBodies Kreis_hohl_HybridBodies = CATIA_Kreis_hohl_Part.Part.HybridBodies;
            HybridBody   Kreis_hohl_HybridBody;

            try
            {
                Kreis_hohl_HybridBody = Kreis_hohl_HybridBodies.Item("Geometrisches Set.1");
            }
            catch (Exception)
            {
                MessageBoxResult result;
                result = MessageBox.Show("CATIA wird nicht ausgeführt!", "Fehler",
                                         MessageBoxButton.OK,
                                         MessageBoxImage.Error
                                         );
                return;
            }
            Kreis_hohl_HybridBody.set_Name("Querschnitt-Skizze");
            Sketches       Kreis_hohl_Sketch         = Kreis_hohl_HybridBody.HybridSketches;
            OriginElements Kreis_hohl_OriginElements = CATIA_Kreis_hohl_Part.Part.OriginElements;
            Reference      Kreis_hohl_Reference      = (Reference)Kreis_hohl_OriginElements.PlaneYZ;

            CATIA_Kreis_hohl_2D = Kreis_hohl_Sketch.Add(Kreis_hohl_Reference);

            ReferenzAchsensystem();

            CATIA_Kreis_hohl_Part.Part.Update();
        }
Пример #5
0
        public void Rechteck_CreateSketch()
        {
            HybridBodies RechteckHybridBodies = CATIA_RechteckPart.Part.HybridBodies;
            HybridBody   RechteckHybridBody;

            try
            {
                RechteckHybridBody = RechteckHybridBodies.Item("Geometrisches Set.1");
            }
            catch (Exception)
            {
                MessageBoxResult result;
                result = MessageBox.Show("CATIA wird nicht ausgeführt!", "Fehler",
                                         MessageBoxButton.OK,
                                         MessageBoxImage.Error
                                         );
                return;
            }
            RechteckHybridBody.set_Name("Querschnitt-Skizze");
            Sketches       RechteckSketch         = RechteckHybridBody.HybridSketches;
            OriginElements RechteckOriginElements = CATIA_RechteckPart.Part.OriginElements;
            Reference      RechteckReference      = (Reference)RechteckOriginElements.PlaneYZ;

            CATIA_Rechteck2D = RechteckSketch.Add(RechteckReference);

            ReferenzAchsensystem();

            CATIA_RechteckPart.Part.Update();
        }
Пример #6
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;
            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();
        }
Пример #7
0
        public void erstelleLeereSkizze()
        {
            HybridBodies catHybridBodies1 = hsp_catiaPart.Part.HybridBodies;
            HybridBody   catHybridBody1   = catHybridBodies1.Item("Geometrisches Set.1");

            catHybridBody1.set_Name("Profile");

            Sketches       catSketches1      = catHybridBody1.HybridSketches;
            OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements;
            Reference      catReference1     = (Reference)catOriginElements.PlaneYZ;

            hsp_catiaProfil = catSketches1.Add(catReference1);
        }
Пример #8
0
        internal void erstelleLeereSkizze()
        {
            HybridBodies catHybridBodies1 = hsp_catiaPart.Part.HybridBodies;
            HybridBody   catHybridBody1;

            catHybridBody1 = catHybridBodies1.Item("Geometrisches Set.1");

            catHybridBody1.set_Name("Profile");                    // Erstelle eine Skizze mit dem Namen Profile
            Sketches catSketches1 = catHybridBody1.HybridSketches; // Mit den genannten die Umrisse erstellen

            Reference catReference1 = (Reference)hsp_catiaPart.Part.OriginElements.PlaneYZ;

            hsp_catiaProfil = catSketches1.Add(catReference1);
        }
Пример #9
0
        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();
        }
Пример #10
0
        public void ErzeugeProfil(Zahnrad Zahnrad1)
        {
            // geometrisches Set auswaehlen und umbenennen
            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");
            // 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();

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

            //Nullpunkt
            double x0 = 0;
            double y0 = 0;

            //Hilfsgrößen von Wilkos PDF
            double Teilkreisradius   = Zahnrad1.d / 2;
            double Hilfskreisradius  = Teilkreisradius * 0.94;
            double Fußkreisradius    = Teilkreisradius - (1.25 * Zahnrad1.m);
            double Kopfkreisradius   = Teilkreisradius + Zahnrad1.m;
            double Verrundungsradius = 0.35 * Zahnrad1.m;

            double Alpha         = 20;
            double Beta          = 90 / Zahnrad1.z;
            double Betarad       = Math.PI * Beta / 180;
            double Gamma         = 90 - (Alpha - Beta);
            double Gammarad      = Math.PI * Gamma / 180;
            double Totalangel    = 360.0 / Zahnrad1.z;
            double Totalangelrad = Math.PI * Totalangel / 180;


            //Punkte
            //LinkerEvolKreis Mittelp. Koordinaten
            double xMPEvo_links = Hilfskreisradius * Math.Cos(Gammarad);
            double yMPEvo_links = Hilfskreisradius * Math.Sin(Gammarad);

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

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

            //Evolventenkreis Radius
            double EvolventenkreisRadius = Math.Sqrt(Math.Pow((xMPEvo_links - xPunktAufEvolvente), 2) + Math.Pow((yMPEvo_links - yPunktAufEvolvente), 2));

            //Koordinaten Schnittpunkt Kopfkreis und Evolventenkreis
            double xEvolventenkopfkreis_links = Schnittpunkt_X(x0, y0, Kopfkreisradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius);
            double yEvolventenkopfkreis_links = Schnittpunkt_Y(x0, y0, Kopfkreisradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius);

            //Mittelpunktkoordinaten Verrundung
            double xMittelpunktVerrundung_links = Schnittpunkt_X(x0, y0, Fußkreisradius + Verrundungsradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius + Verrundungsradius);
            double yMittelpunktVerrundung_links = Schnittpunkt_Y(x0, y0, Fußkreisradius + Verrundungsradius, xMPEvo_links, yMPEvo_links, EvolventenkreisRadius + Verrundungsradius);

            //Schnittpubktkoordinaten Verrundung - Evolventenkreis
            double x_SP_EvolventeVerrundung_links = Schnittpunkt_X(xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius);
            double y_SP_EvolventeVerrundung_links = Schnittpunkt_Y(xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, xMittelpunktVerrundung_links, yMittelpunktVerrundung_links, Verrundungsradius);

            //Schnittpunktkoordinaten 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);

            //Koordinaten 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);

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

            //Nun die Punkte in die Skizze
            Point2D Ursprung = catfactory2D1.CreatePoint(x0, y0);
            Point2D EndpunktEvolventenkreis = catfactory2D1.CreatePoint(x_AnfangspunktFußkreis, y_AnfangspunktFußkreis);
            Point2D VerrundungLinksAnfang   = catfactory2D1.CreatePoint(x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links);
            Point2D VerrundungRechtsEnde    = catfactory2D1.CreatePoint(-x_SP_FußkreisradiusVerrundung_links, y_SP_FußkreisradiusVerrundung_links);
            Point2D MPVerrundungLinks       = catfactory2D1.CreatePoint(xMittelpunktVerrundung_links, yMittelpunktVerrundung_links);
            Point2D MPVerrundungRechts      = catfactory2D1.CreatePoint(-xMittelpunktVerrundung_links, yMittelpunktVerrundung_links);
            Point2D VerrundungEndeLinks     = catfactory2D1.CreatePoint(x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links);
            Point2D VerrundungAnfangRechts  = catfactory2D1.CreatePoint(-x_SP_EvolventeVerrundung_links, y_SP_EvolventeVerrundung_links);
            Point2D MPEvolventeLinks        = catfactory2D1.CreatePoint(xMPEvo_links, yMPEvo_links);
            Point2D MPEvolventeRechts       = catfactory2D1.CreatePoint(-xMPEvo_links, yMPEvo_links);
            Point2D EvolventenEndeLinks     = catfactory2D1.CreatePoint(xEvolventenkopfkreis_links, yEvolventenkopfkreis_links);
            Point2D EvolventenEndeRechts    = catfactory2D1.CreatePoint(-xEvolventenkopfkreis_links, yEvolventenkopfkreis_links);

            //Kreise

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

            Fußkreis.CenterPoint = Ursprung;
            Fußkreis.StartPoint  = EndpunktEvolventenkreis;
            Fußkreis.EndPoint    = VerrundungRechtsEnde;

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

            VerrundungLinks.CenterPoint = MPVerrundungLinks;
            VerrundungLinks.StartPoint  = VerrundungLinksAnfang;
            VerrundungLinks.EndPoint    = VerrundungEndeLinks;

            Circle2D EvolventenkreisLinks = catfactory2D1.CreateCircle(xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, 0, Math.PI * 2);

            EvolventenkreisLinks.CenterPoint = MPEvolventeLinks;
            EvolventenkreisLinks.StartPoint  = EvolventenEndeLinks;
            EvolventenkreisLinks.EndPoint    = VerrundungEndeLinks;

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

            Kopfkreis.CenterPoint = Ursprung;
            Kopfkreis.StartPoint  = EvolventenEndeRechts;
            Kopfkreis.EndPoint    = EvolventenEndeLinks;

            Circle2D EvolventenkreisRechts = catfactory2D1.CreateCircle(-xMPEvo_links, yMPEvo_links, EvolventenkreisRadius, 0, Math.PI * 2);

            EvolventenkreisRechts.CenterPoint = MPEvolventeRechts;
            EvolventenkreisRechts.StartPoint  = VerrundungAnfangRechts;
            EvolventenkreisRechts.EndPoint    = EvolventenEndeRechts;

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

            VerrundungRechts.CenterPoint = MPVerrundungRechts;
            VerrundungRechts.StartPoint  = VerrundungAnfangRechts;
            VerrundungRechts.EndPoint    = VerrundungRechtsEnde;

            // Skizzierer verlassen
            hsp_catiaProfil.CloseEdition();
            // Part aktualisieren
            hsp_catiaPart.Part.Update();

            ShapeFactory       shapeFactory1       = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;
            HybridShapeFactory hybridShapeFactory1 = (HybridShapeFactory)hsp_catiaPart.Part.HybridShapeFactory;

            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 / Zahnrad1.z);
            AngularRepartition angularRepartition2 = kreismuster.AngularRepartition;
            IntParam           intParam1           = angularRepartition2.InstancesCount;

            intParam1.Value = Convert.ToInt32(Zahnrad1.z) + 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);

            hsp_catiaPart.Part.Update();

            ErzeugeBlock(Zahnrad1, refVerbindung, shapeFactory1);


            Sketches       sketchesBohrung   = catHybridBody1.HybridSketches;
            OriginElements catoriginelements = hsp_catiaPart.Part.OriginElements;
            Reference      refmxPlaneX       = (Reference)catoriginelements.PlaneYZ;

            hsp_catiaProfil = catSketches1.Add(refmxPlaneX);

            ErzeugeAchsensystem();

            hsp_catiaPart.Part.Update();

            hsp_catiaProfil.set_Name("Bohrung");

            Factory2D catfactory2D2 = hsp_catiaProfil.OpenEdition();

            Circle2D KreisFürBohrungsskizze = catfactory2D2.CreateClosedCircle(x0, y0, Zahnrad1.bd / 2);

            hsp_catiaProfil.CloseEdition();

            hsp_catiaPart.Part.Update();

            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;
            Pocket Tasche = shapeFactory1.AddNewPocket(hsp_catiaProfil, Zahnrad1.b);

            hsp_catiaPart.Part.Update();
        }
Пример #11
0
        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();
        }
Пример #12
0
        public void Senkkopf(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.PlaneZX;
            hsp_catiaProfil = catSketches1.Add(catReference1);


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

            Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition();
            #endregion

            #region Profil
            double tan45 = 1;
            double tan30 = Math.Sqrt(3) / 3;
            double winkel;
            if (m.bezeichnung <= 20)
            {
                winkel = tan45;
            }
            else
            {
                winkel = tan30;
            }

            double HoeheP4 = ((m.innenskkopfdurchmesser / 2) - (m.bezeichnung / 2)) / winkel;
            // erst die Punkte
            Point2D catPoint2D1 = catFactory2D1.CreatePoint(0, 0);
            Point2D catPoint2D2 = catFactory2D1.CreatePoint(m.innenskkopfhöhe, 0);
            Point2D catPoint2D3 = catFactory2D1.CreatePoint(m.innenskkopfhöhe, m.innenskkopfdurchmesser / 2);
            Point2D catPoint2D4 = catFactory2D1.CreatePoint(HoeheP4, m.innenskkopfdurchmesser / 2);
            Point2D catPoint2D5 = catFactory2D1.CreatePoint(0, m.bezeichnung / 2);

            // dann das Profil
            Line2D catLine2D1 = catFactory2D1.CreateLine(0, 0, m.innenskkopfhöhe, 0);
            catLine2D1.StartPoint = catPoint2D1;
            catLine2D1.EndPoint   = catPoint2D2;

            Line2D catLine2D2 = catFactory2D1.CreateLine(m.innenskkopfhöhe, 0, m.innenskkopfhöhe, m.innenskkopfdurchmesser / 2);
            catLine2D2.StartPoint = catPoint2D2;
            catLine2D2.EndPoint   = catPoint2D3;

            Line2D catLine2D3 = catFactory2D1.CreateLine(m.innenskkopfhöhe, m.innenskkopfdurchmesser / 2, HoeheP4, m.innenskkopfdurchmesser / 2);
            catLine2D3.StartPoint = catPoint2D3;
            catLine2D3.EndPoint   = catPoint2D4;

            Line2D catLine2D4 = catFactory2D1.CreateLine(HoeheP4, m.innenskkopfdurchmesser / 2, 0, m.bezeichnung / 2);
            catLine2D4.StartPoint = catPoint2D4;
            catLine2D4.EndPoint   = catPoint2D5;

            Line2D catLine2D5 = catFactory2D1.CreateLine(0, m.bezeichnung / 2, 0, 0);
            catLine2D5.StartPoint = catPoint2D5;
            catLine2D5.EndPoint   = catPoint2D1;

            Point2D AxisPoint1 = catFactory2D1.CreatePoint(0, 0);
            Point2D AxisPoint2 = catFactory2D1.CreatePoint(m.innenskkopfhöhe, 0);

            Line2D AxisLine1 = catFactory2D1.CreateLine(0, 0, m.innenskkopfhöhe, 0);
            AxisLine1.StartPoint = AxisPoint1;
            AxisLine1.EndPoint   = AxisPoint2;

            Reference         Axisreference1     = hsp_catiaPart.Part.CreateReferenceFromObject(AxisPoint1);
            GeometricElements geometricElements1 = hsp_catiaProfil.GeometricElements;
            Axis2D            catAxis2D1         = (Axis2D)geometricElements1.Item("Absolute Achse");
            Line2D            AxisLine2          = (Line2D)catAxis2D1.GetItem("H-Richtung");

            Reference   Axisreference2 = hsp_catiaPart.Part.CreateReferenceFromObject(AxisLine2);
            Constraints constraints1   = hsp_catiaProfil.Constraints;
            Constraint  constraint1    = constraints1.AddBiEltCst(CatConstraintType.catCstTypeOn, Axisreference1, Axisreference2);
            constraint1.Mode = CatConstraintMode.catCstModeDrivingDimension;

            Reference  Axisreference3 = hsp_catiaPart.Part.CreateReferenceFromObject(AxisLine1);
            Reference  Axisreference4 = hsp_catiaPart.Part.CreateReferenceFromObject(AxisLine2);
            Constraint constraint2    = constraints1.AddBiEltCst(CatConstraintType.catCstTypeVerticality, Axisreference3, Axisreference4);
            constraint2.Mode = CatConstraintMode.catCstModeDrivingDimension;

            hsp_catiaProfil.CenterLine = AxisLine1;


            // Skizzierer verlassen
            hsp_catiaProfil.CloseEdition();

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

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


            ShapeFactory catShapeFactory1 = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;
            Reference    reference1       = hsp_catiaPart.Part.CreateReferenceFromObject(hsp_catiaProfil);
            SenkkopfShaft = catShapeFactory1.AddNewShaftFromRef(reference1);
            SenkkopfShaft.SetProfileElement(reference1);

            SenkkopfShaft.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.innenskkopfhöhe, 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 Innensechskant
            Factory2D catFactory2D2 = SkizzeaufOffset.OpenEdition();

            // Sechskant erzeugen

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

            // erst die Punkte
            Point2D catPoint2D6  = catFactory2D2.CreatePoint(mSW, tan30 * mSW);
            Point2D catPoint2D7  = catFactory2D2.CreatePoint(mSW, -(tan30 * mSW));
            Point2D catPoint2D8  = catFactory2D2.CreatePoint(0, -(mSW / cos30));
            Point2D catPoint2D9  = catFactory2D2.CreatePoint(-mSW, -(tan30 * mSW));
            Point2D catPoint2D10 = catFactory2D2.CreatePoint(-mSW, tan30 * mSW);
            Point2D catPoint2D11 = catFactory2D2.CreatePoint(0, mSW / cos30);

            // dann die Linien
            Line2D catLine2D6 = catFactory2D2.CreateLine(mSW, tan30 * mSW, mSW, -(tan30 * mSW));
            catLine2D6.StartPoint = catPoint2D6;
            catLine2D6.EndPoint   = catPoint2D7;

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

            Line2D catLine2D8 = catFactory2D2.CreateLine(0, -(mSW / cos30), -mSW, -(tan30 * mSW));
            catLine2D8.StartPoint = catPoint2D8;
            catLine2D8.EndPoint   = catPoint2D9;

            Line2D catLine2D9 = catFactory2D2.CreateLine(-mSW, -(tan30 * mSW), -mSW, (tan30 * mSW));
            catLine2D9.StartPoint = catPoint2D9;
            catLine2D9.EndPoint   = catPoint2D10;

            Line2D catLine2D10 = catFactory2D2.CreateLine(-mSW, (tan30 * mSW), 0, mSW / cos30);
            catLine2D10.StartPoint = catPoint2D10;
            catLine2D10.EndPoint   = catPoint2D11;

            Line2D catLine2D11 = catFactory2D2.CreateLine(0, mSW / cos30, mSW, tan30 * mSW);
            catLine2D11.StartPoint = catPoint2D11;
            catLine2D11.EndPoint   = catPoint2D6;

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

            #region Tasche Innensechskant
            // 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.schlitztiefe);

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

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion
        }
Пример #13
0
        public void Sechskantverrundung(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.PlaneZX;
            hsp_catiaProfil = catSketches1.Add(catReference1);


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

            Factory2D catFactory2D1 = hsp_catiaProfil.OpenEdition();
            #endregion

            #region Profil zeichnen

            double tan30  = Math.Sqrt(3) / 3;
            double cos30  = Math.Sqrt(3) / 2;
            double mSW    = (m.schluesselweite / 2);
            double Breite = (mSW / cos30);

            Point2D catPoint2D1 = catFactory2D1.CreatePoint(m.kopfhoehesechs, mSW * 0.95);
            Point2D catPoint2D2 = catFactory2D1.CreatePoint(m.kopfhoehesechs, Breite);
            Point2D catPoint2D3 = catFactory2D1.CreatePoint(m.kopfhoehesechs - (tan30 * (Breite - mSW)), Breite);

            Line2D catLine2D1 = catFactory2D1.CreateLine(m.kopfhoehesechs, mSW * 0.95, m.kopfhoehesechs, Breite);
            catLine2D1.StartPoint = catPoint2D1;
            catLine2D1.EndPoint   = catPoint2D2;

            Line2D catLine2D2 = catFactory2D1.CreateLine(m.kopfhoehesechs, Breite, m.kopfhoehesechs - (tan30 * (Breite - mSW)), Breite);
            catLine2D2.StartPoint = catPoint2D2;
            catLine2D2.EndPoint   = catPoint2D3;

            Line2D catLine2D3 = catFactory2D1.CreateLine(m.kopfhoehesechs - (tan30 * (Breite - mSW)), Breite, m.kopfhoehesechs, mSW * 0.95);
            catLine2D3.StartPoint = catPoint2D3;
            catLine2D3.EndPoint   = catPoint2D1;

            Point2D AxisPoint1 = catFactory2D1.CreatePoint(0, 0);
            Point2D AxisPoint2 = catFactory2D1.CreatePoint(m.kopfhoehesechs, 0);

            Line2D AxisLine1 = catFactory2D1.CreateLine(0, 0, m.kopfhoehesechs, 0);
            AxisLine1.StartPoint = AxisPoint1;
            AxisLine1.EndPoint   = AxisPoint2;

            Reference         Axisreference1     = hsp_catiaPart.Part.CreateReferenceFromObject(AxisPoint1);
            GeometricElements geometricElements1 = hsp_catiaProfil.GeometricElements;
            Axis2D            catAxis2D1         = (Axis2D)geometricElements1.Item("Absolute Achse");
            Line2D            AxisLine2          = (Line2D)catAxis2D1.GetItem("H-Richtung");

            Reference   Axisreference2 = hsp_catiaPart.Part.CreateReferenceFromObject(AxisLine2);
            Constraints constraints1   = hsp_catiaProfil.Constraints;
            Constraint  constraint1    = constraints1.AddBiEltCst(CatConstraintType.catCstTypeOn, Axisreference1, Axisreference2);
            constraint1.Mode = CatConstraintMode.catCstModeDrivingDimension;

            Reference  Axisreference3 = hsp_catiaPart.Part.CreateReferenceFromObject(AxisLine1);
            Reference  Axisreference4 = hsp_catiaPart.Part.CreateReferenceFromObject(AxisLine2);
            Constraint constraint2    = constraints1.AddBiEltCst(CatConstraintType.catCstTypeVerticality, Axisreference3, Axisreference4);
            constraint2.Mode = CatConstraintMode.catCstModeDrivingDimension;

            hsp_catiaProfil.CenterLine = AxisLine1;

            // Skizzierer verlassen
            hsp_catiaProfil.CloseEdition();

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

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


            ShapeFactory catShapeFactory1 = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;
            Reference    reference1       = hsp_catiaPart.Part.CreateReferenceFromObject(hsp_catiaProfil);
            SechskantGroove = catShapeFactory1.AddNewGrooveFromRef(reference1);
            SechskantGroove.SetProfileElement(reference1);

            SechskantGroove.set_Name("Kopfnut");

            // Part aktualisieren
            hsp_catiaPart.Part.Update();
            #endregion
        }
Пример #14
0
        //Außenverzahntes Stirnrad
        public void ErzeugeProfilAußen(Data dat)
        {
            //ERZEUGE SKIZZE
            //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");
            Sketches       catSketches1      = catHybridBody1.HybridSketches;
            OriginElements catOriginElements = hsp_catiaPart.Part.OriginElements;
            Reference      catReference1     = (Reference)catOriginElements.PlaneYZ;

            hsp_catiaProfil = catSketches1.Add(catReference1);

            //Erstelle Achsensystem

            ErzeugeAchsensystem();

            //Update
            hsp_catiaPart.Part.Update();



            //KOORDINATEN ANLEGEN
            //Nullpunkt
            double x0 = 0;
            double y0 = 0;

            //Radien und Winkel
            double teilkreisradius   = dat.getTeilkreisdurchmesser() / 2;
            double hilfskreisradius  = teilkreisradius * 0.94;
            double fußkreisradius    = teilkreisradius - (1.25 * dat.getModul());
            double kopfkreisradius   = 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 totalangle    = 360.0 / dat.getZähnezahl();
            double totalanglerad = Math.PI * totalangle / 180;

            //Schnittpunkte und Koordinaten
            //Evolventenkreis Center Koordinaten
            double mittelpunktEvol_x = hilfskreisradius * Math.Cos(gammarad);
            double mittelpunktEvol_y = hilfskreisradius * Math.Sin(gammarad);

            //Schnittpkt. der Evolvente und dem Teilkreisradius
            double punktEvol_x = -teilkreisradius *Math.Sin(betarad);

            double punktEvol_y = teilkreisradius * Math.Cos(betarad);

            //Evolvente Radius
            double EvolventenkreisRadius = Math.Sqrt(Math.Pow((mittelpunktEvol_x - punktEvol_x), 2) + Math.Pow((mittelpunktEvol_y - punktEvol_y), 2));

            //Schnittpunkt Kopfkreis und Evolventenkreis
            double evolventenKopfk_x = Schnittpunkt_X(x0, y0, kopfkreisradius, mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius);
            double evolventenKopfk_y = Schnittpunkt_Y(x0, y0, kopfkreisradius, mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius);

            //Center Verrundung
            double mittelpunktVer_x = Schnittpunkt_X(x0, y0, fußkreisradius + verrundungsradius, mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius + verrundungsradius);
            double mittelpunktVer_y = Schnittpunkt_Y(x0, y0, fußkreisradius + verrundungsradius, mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius + verrundungsradius);

            //Schnittpunkt Verrundung Evolventenkreis
            double evolventenVer_x = Schnittpunkt_X(mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius, mittelpunktVer_x, mittelpunktVer_y, verrundungsradius);
            double evolventenVer_y = Schnittpunkt_Y(mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius, mittelpunktVer_x, mittelpunktVer_y, verrundungsradius);

            //Schnittpunkt Verrundung Fußkreis
            double fußkreisVer_x = Schnittpunkt_X(x0, y0, fußkreisradius, mittelpunktVer_x, mittelpunktVer_y, verrundungsradius);
            double fußkreisVer_y = Schnittpunkt_Y(x0, y0, fußkreisradius, mittelpunktVer_x, mittelpunktVer_y, verrundungsradius);

            //Anfangspunkt Fußkreis
            double hilfswinkel        = totalanglerad - Math.Atan(Math.Abs(fußkreisVer_x) / Math.Abs(fußkreisVer_y));
            double anfangspunktFußk_x = -fußkreisradius *Math.Sin(hilfswinkel);

            double anfangspunktFußk_y = fußkreisradius * Math.Cos(hilfswinkel);

            //Skizze umbenennen und öffnen
            hsp_catiaProfil.set_Name("Außenverzahntes Stirnrad");
            Factory2D catfactory2D1 = hsp_catiaProfil.OpenEdition();

            //Punkte in Skizze einzeichnen
            Point2D point_Ursprung             = catfactory2D1.CreatePoint(x0, y0);
            Point2D pointAnfangFußkreis        = catfactory2D1.CreatePoint(anfangspunktFußk_x, anfangspunktFußk_y);
            Point2D pointFußkreisVer_l         = catfactory2D1.CreatePoint(fußkreisVer_x, fußkreisVer_y);
            Point2D pointFußkreisVer_r         = catfactory2D1.CreatePoint(-fußkreisVer_x, fußkreisVer_y);
            Point2D pointMittelpunktVer_l      = catfactory2D1.CreatePoint(mittelpunktVer_x, mittelpunktVer_y);
            Point2D pointMittelpunktVer_r      = catfactory2D1.CreatePoint(-mittelpunktVer_x, mittelpunktVer_y);
            Point2D pointVerrundungEvol_l      = catfactory2D1.CreatePoint(evolventenVer_x, evolventenVer_y);
            Point2D pointVerrundungEvol_r      = catfactory2D1.CreatePoint(-evolventenVer_x, evolventenVer_y);
            Point2D pointMittelpunktevol_l     = catfactory2D1.CreatePoint(mittelpunktEvol_x, mittelpunktEvol_y);
            Point2D pointMittelpunktevol_r     = catfactory2D1.CreatePoint(-mittelpunktEvol_x, mittelpunktEvol_y);
            Point2D pointEvolventenKopfkreis_l = catfactory2D1.CreatePoint(evolventenKopfk_x, evolventenKopfk_y);
            Point2D pointEvolventenKopfkreis_r = catfactory2D1.CreatePoint(-evolventenKopfk_x, evolventenKopfk_y);

            //Kreise in Skizze einzeichnen
            Circle2D kreisFußkreis = catfactory2D1.CreateCircle(x0, y0, fußkreisradius, 0, Math.PI * 2);

            kreisFußkreis.CenterPoint = point_Ursprung;
            kreisFußkreis.StartPoint  = pointFußkreisVer_l;
            kreisFußkreis.EndPoint    = pointAnfangFußkreis;

            Circle2D kreisVerrundung_l = catfactory2D1.CreateCircle(mittelpunktVer_x, mittelpunktVer_y, verrundungsradius, 0, Math.PI * 2);

            kreisVerrundung_l.CenterPoint = pointMittelpunktVer_l;
            kreisVerrundung_l.StartPoint  = pointFußkreisVer_l;
            kreisVerrundung_l.EndPoint    = pointVerrundungEvol_l;

            Circle2D kreisEvolventenkreis_l = catfactory2D1.CreateCircle(mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius, 0, Math.PI * 2);

            kreisEvolventenkreis_l.CenterPoint = pointMittelpunktevol_l;
            kreisEvolventenkreis_l.StartPoint  = pointEvolventenKopfkreis_l;
            kreisEvolventenkreis_l.EndPoint    = pointVerrundungEvol_l;

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

            kreisKopfkreis.CenterPoint = point_Ursprung;
            kreisKopfkreis.StartPoint  = pointEvolventenKopfkreis_r;
            kreisKopfkreis.EndPoint    = pointEvolventenKopfkreis_l;

            Circle2D kreisEvolventenkreis_r = catfactory2D1.CreateCircle(-mittelpunktEvol_x, mittelpunktEvol_y, EvolventenkreisRadius, 0, Math.PI * 2);

            kreisEvolventenkreis_r.CenterPoint = pointMittelpunktevol_r;
            kreisEvolventenkreis_r.StartPoint  = pointVerrundungEvol_r;
            kreisEvolventenkreis_r.EndPoint    = pointEvolventenKopfkreis_r;

            Circle2D kreisVerrundung_r = catfactory2D1.CreateCircle(-mittelpunktVer_x, mittelpunktVer_y, verrundungsradius, 0, Math.PI * 2);

            kreisVerrundung_r.CenterPoint = pointMittelpunktVer_r;
            kreisVerrundung_r.StartPoint  = pointVerrundungEvol_r;
            kreisVerrundung_r.EndPoint    = pointFußkreisVer_r;


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

            //Update
            hsp_catiaPart.Part.Update();



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

            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();


            //ERSTELLE BLOCK
            ErzeugeBlock(refVerbindung, shapeFactory1, dat);


            if (dat.Bohrungsauswahl == 1)
            {
                //Skizze
                Sketches       sketchesBohrung   = catHybridBody1.HybridSketches;
                OriginElements catoriginelements = hsp_catiaPart.Part.OriginElements;
                Reference      refmxPlaneX       = (Reference)catoriginelements.PlaneYZ;
                hsp_catiaProfil = catSketches1.Add(refmxPlaneX);

                //Achsensystem
                ErzeugeAchsensystem();

                //Update
                hsp_catiaPart.Part.Update();

                //Skizze Umbennen
                hsp_catiaProfil.set_Name("Bohrung");

                //Öffnen
                Factory2D catfactory2D2 = hsp_catiaProfil.OpenEdition();

                //Kreis
                Circle2D KreisFürBohrungsskizze = catfactory2D2.CreateClosedCircle(x0, y0, dat.getBohrung());

                //Schließen
                hsp_catiaProfil.CloseEdition();

                //Update
                hsp_catiaPart.Part.Update();

                //Tasche
                hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;
                Pocket Tasche = shapeFactory1.AddNewPocket(hsp_catiaProfil, dat.getBreite());
                hsp_catiaPart.Part.Update();
            }
            if (dat.Bohrungsauswahl == 2)
            {
                //Schnittpunkte und Koordinaten
                //LH Schnittpunkt Passfederhöhe mit Bohrung
                double x_AnfangkreisZuPassfeder = -dat.getPassfederbreite() / 2;
                double y_AnfangkreisZuPassfeder = Math.Sqrt(Math.Pow(dat.getBohrung(), 2) - Math.Pow((dat.getPassfederbreite() / 2), 2));

                //LH Schnittpunkt Breite und Höhe
                double x_Passfederecke = -dat.getPassfederbreite() / 2;
                double y_Passfederecke = dat.getPassfederhöhe();

                //Skizze
                Sketches       sketchesBohrung   = catHybridBody1.HybridSketches;
                OriginElements catoriginelements = hsp_catiaPart.Part.OriginElements;
                Reference      refmxPlaneX       = (Reference)catoriginelements.PlaneYZ;
                hsp_catiaProfil = catSketches1.Add(refmxPlaneX);

                //Achsensystem
                ErzeugeAchsensystem();

                //Update
                hsp_catiaPart.Part.Update();

                //Umbennen und öffnen
                hsp_catiaProfil.set_Name("Bohrung mit Passfedernut");
                Factory2D catfactory2D2 = hsp_catiaProfil.OpenEdition();



                //Punkte in Skizze einzeichnen
                Point2D POINTLinksAnfangKreisZuPassfeder  = catfactory2D2.CreatePoint(x_AnfangkreisZuPassfeder, y_AnfangkreisZuPassfeder);
                Point2D POINTLinksPassfederEcke           = catfactory2D2.CreatePoint(x_Passfederecke, y_Passfederecke);
                Point2D POINTRechtsPassfederEcke          = catfactory2D2.CreatePoint(-x_Passfederecke, y_Passfederecke);
                Point2D POINTRechtsAnfangKreisZuPassfeder = catfactory2D2.CreatePoint(-x_AnfangkreisZuPassfeder, y_AnfangkreisZuPassfeder);

                //Linien einzeichnen
                Line2D PassfederKanteLinks = catfactory2D2.CreateLine(x_AnfangkreisZuPassfeder, y_AnfangkreisZuPassfeder, x_Passfederecke, y_Passfederecke);
                PassfederKanteLinks.StartPoint = POINTLinksAnfangKreisZuPassfeder;
                PassfederKanteLinks.EndPoint   = POINTLinksPassfederEcke;

                Line2D PassfederHöhenkante = catfactory2D2.CreateLine(x_Passfederecke, y_Passfederecke, -x_Passfederecke, y_Passfederecke);
                PassfederHöhenkante.StartPoint = POINTLinksPassfederEcke;
                PassfederHöhenkante.EndPoint   = POINTRechtsPassfederEcke;

                Line2D PassfederKanteRechts = catfactory2D2.CreateLine(-x_Passfederecke, y_Passfederecke, -x_AnfangkreisZuPassfeder, y_AnfangkreisZuPassfeder);
                PassfederKanteRechts.StartPoint = POINTRechtsPassfederEcke;
                PassfederKanteRechts.EndPoint   = POINTRechtsAnfangKreisZuPassfeder;

                Circle2D KreisFürPassfeder = catfactory2D2.CreateCircle(x0, y0, dat.getBohrung(), 0, Math.PI * 2);
                KreisFürPassfeder.CenterPoint = point_Ursprung;
                KreisFürPassfeder.EndPoint    = POINTRechtsAnfangKreisZuPassfeder;
                KreisFürPassfeder.StartPoint  = POINTLinksAnfangKreisZuPassfeder;

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


                //Update
                hsp_catiaPart.Part.Update();

                //Tasche
                hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;
                Pocket Tasche = shapeFactory1.AddNewPocket(hsp_catiaProfil, dat.getBreite());
                hsp_catiaPart.Part.Update();
            }
        }
Пример #15
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();
        }
Пример #16
0
        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();
        }
Пример #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            INFITF.Application catia;        //INFITF.Application; returntype, catia; 변수명

            try
            {
                catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application"); //실행되 있는 카티아 가져오기
            }
            catch (Exception ex)
            {
                //MessageBox.Show("카티아가 실행돼 있지 않습니다.");
                //MessageBox.Show("카티아 가져오기 오류: "+ex.Message);
                //catia 열기
                catia         = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
                catia.Visible = true;
            }
            //creat a part

            /*
             * catia.Documents.Add("Part1");
             * //catia.Documents.Open();
             * MECMOD.PartDocument part1;
             */
            MECMOD.PartDocument partDoc;
            partDoc = (MECMOD.PartDocument)catia.Documents.Add("Part");

            MECMOD.Part prt = partDoc.Part; //partDoc에 part를 담은 것

            MECMOD.Bodies bodies = prt.Bodies;

            MECMOD.Body body = bodies.Add();    //다름 body만들기
            //MECMOD.Body body0 = bodies.Item(1); //생성되 있는 partbody가져오기
            //MECMOD.Body body2 = bodies.Item("PartBody"); //해당되는 것에 이름
            //MECMOD.Body body1 = prt.MainBody;   //partbody가져오기

            MECMOD.Sketches skts = body.Sketches;

            INFITF.Reference xyPln = (INFITF.Reference)prt.OriginElements.PlaneXY; //creat a plan

            MECMOD.Sketch skt = skts.Add(xyPln);                                   //plane에 skt를 작성한다.
                                                                                   //open the skt
            MECMOD.Factory2D fac2d = skt.OpenEdition();

            //6.create the points
            MECMOD.GeometricElements gme = prt.GeometricElements;
            MECMOD.Point2D           p1  = fac2d.CreatePoint(10, 10);
            MECMOD.Point2D           p2  = fac2d.CreatePoint(10, 40);
            MECMOD.Point2D           p3  = fac2d.CreatePoint(40, 40);
            MECMOD.Point2D           p4  = fac2d.CreatePoint(40, 10);
            MECMOD.Point2D           p5  = fac2d.CreatePoint(30, 20);
            MECMOD.Point2D           p6  = fac2d.CreatePoint(20, 5);

            //7.create the lines
            MECMOD.Line2D line1 = fac2d.CreateLine(10, 10, 10, 40);
            MECMOD.Line2D line2 = fac2d.CreateLine(10, 40, 40, 40);
            MECMOD.Line2D line3 = fac2d.CreateLine(40, 40, 40, 10);

            //8.9 create  the spline
            Object[]        pa     = { p1, p6, p5, p4 };
            MECMOD.Spline2D spline = fac2d.CreateSpline(pa);

            //구속조건 추가
            //10
            line1.StartPoint = p1;
            line1.EndPoint   = p2;

            line2.StartPoint = p2;
            line2.EndPoint   = p3;

            line3.StartPoint = p3;
            line3.EndPoint   = p4;

            //11.create references
            INFITF.Reference rline1 = prt.CreateReferenceFromGeometry(line1);
            INFITF.Reference rline2 = prt.CreateReferenceFromGeometry(line2);

            INFITF.Reference rline3 = prt.CreateReferenceFromGeometry(line3);

            //12.
            MECMOD.Constraint cns = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeAxisPerpendicularity, rline1, rline2);

            MECMOD.Constraint cns1 = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeAxisPerpendicularity, rline3, rline2);

            //13.
            skt.CloseEdition();

            //catia.Visible = true;
        }
Пример #18
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);
        }
Пример #19
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
        }