예제 #1
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();
        }
예제 #2
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
        }
예제 #3
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
        }