コード例 #1
0
        public static void CreateCam(double angle)
        {
            double dRad   = angle * dPi / 180;
            double dDSin1 = iCircle1Rad * Math.Sin(dRad);
            double dDCos1 = iCircle1Rad * Math.Cos(dRad);
            double dDSin2 = iCircle2Rad * Math.Sin(dRad);
            double dDCos2 = iCircle2Rad * Math.Cos(dRad);
            double dCSin  = iCircleDist * Math.Sin(dRad);
            double dCCos  = iCircleDist * Math.Cos(dRad);

            oCurrentSketch = oPartBody.Sketches.Add(oPlaneYZ);
            Factory2D oFactory2D = oCurrentSketch.OpenEdition();
            double    dRad1      = dRad - dPi / 4;
            double    dRad2      = dRad + dPi / 4;

            oCurrentLine1   = oFactory2D.CreateLine(iCenterX - dDSin1, iCenterY + dDCos1, iCenterX + dCCos + dDSin2, iCenterY - dCSin + dDCos2);
            oCurrentLine2   = oFactory2D.CreateLine(iCenterX + dDSin1, iCenterY - dDCos1, iCenterX + dCCos - dDSin2, iCenterY - dCSin - dDCos2);
            oCurrentCircle1 = oFactory2D.CreateCircle(iCenterX, iCenterY, iCircle1Rad, dRad2, dRad1);
            oCurrentCircle2 = oFactory2D.CreateCircle(iCenterX + dCCos, iCenterY + dCSin, iCircle2Rad, dRad1, dRad2);
            Reference   oRefLine1          = oPart.CreateReferenceFromObject(oCurrentLine1);
            Reference   oRefCircle1        = oPart.CreateReferenceFromObject(oCurrentCircle1);
            Reference   oRefLine2          = oPart.CreateReferenceFromObject(oCurrentLine2);
            Reference   oRefCircle2        = oPart.CreateReferenceFromObject(oCurrentCircle2);
            Reference   oRefLine1StartPt   = oPart.CreateReferenceFromObject(oCurrentLine1.StartPoint);
            Reference   oRefLine1EndPt     = oPart.CreateReferenceFromObject(oCurrentLine1.EndPoint);
            Reference   oRefLine2StartPt   = oPart.CreateReferenceFromObject(oCurrentLine2.StartPoint);
            Reference   oRefLine2EndPt     = oPart.CreateReferenceFromObject(oCurrentLine2.EndPoint);
            Reference   oRefCircle1StartPt = oPart.CreateReferenceFromObject(oCurrentCircle1.StartPoint);
            Reference   oRefCircle1EndPt   = oPart.CreateReferenceFromObject(oCurrentCircle1.EndPoint);
            Reference   oRefCircle2StartPt = oPart.CreateReferenceFromObject(oCurrentCircle2.StartPoint);
            Reference   oRefCircle2EndPt   = oPart.CreateReferenceFromObject(oCurrentCircle2.EndPoint);
            Constraints oConstraints       = oCurrentSketch.Constraints;
            Constraint  oConstraint        = oConstraints.AddMonoEltCst(CatConstraintType.catCstTypeReference, oRefCircle1);

            oConstraint = oConstraints.AddMonoEltCst(CatConstraintType.catCstTypeReference, oRefCircle2);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefLine1, oRefCircle1);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefCircle2, oRefLine1);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle1StartPt, oRefLine1StartPt);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle2EndPt, oRefLine1EndPt);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefLine2, oRefCircle1);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeTangency, oRefLine2, oRefCircle2);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle1EndPt, oRefLine2StartPt);
            oConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, oRefCircle2StartPt, oRefLine2EndPt);
            oCurrentSketch.CloseEdition();
            ShapeFactory oShapeFactory = (ShapeFactory)oPart.ShapeFactory;
            Pad          oPad          = oShapeFactory.AddNewPad(oCurrentSketch, iCamThickness + iCurrentLevel);

            oPad.SecondLimit.Dimension.Value = iCurrentLevel * -1;
        }
コード例 #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 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
        }