// Post
        public override void TranslateT2C(TransCAD.IFeature tFeature)
        {
            TransCAD.IStdSolidChamferFeature tChamfer = (TransCAD.IStdSolidChamferFeature)tFeature;

            double length = tChamfer.Length;

            TransCAD.ChamferType chamferType = tChamfer.ChamferType;

            PARTITF.Chamfer cChamfer = PartManager.cShapeFactory.AddNewChamfer(null, PARTITF.CatChamferPropagation.catMinimalChamfer, PARTITF.CatChamferMode.catTwoLengthChamfer, PARTITF.CatChamferOrientation.catNoReverseChamfer, length, length);

            IEnumerator edges = tChamfer.SelectedEdges.GetEnumerator();

            while (edges.MoveNext())
            {
                TransCAD.Reference edge = (TransCAD.Reference)edges.Current;

                string           cRefName = PartManager.ReferenceManager.GetCATIANameFromTransCADName(edge.ReferenceeName);
                INFITF.Reference cRef     = PartManager.cPart.CreateReferenceFromBRepName(cRefName, PartManager.GetRecentFeature());

                cChamfer.AddElementToChamfer(cRef);
            }

            PartManager.cPart.UpdateObject(cChamfer);
            PartManager.ReferenceManager.NameMap.Add(tChamfer.Name, cChamfer.get_Name());
        }
예제 #2
0
        // create lines
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                prtDoc = (PartDocument)catia.ActiveDocument;
                Part prt = prtDoc.Part;
                hbdy = prt.HybridBodies.Item(1);
                HybridShapeFactory hfac = (HybridShapeFactory)prt.HybridShapeFactory;
                //SelGS = (HybridBody)Sel.Item(1).Value;

                //INFITF.AnyObject aaa = Pts[0];
                for (int i = 0; i <= (Pts.Count - 1); i++)
                {
                    for (int j = i + 1; j < Pts.Count; j++)
                    {
                        HybridShapeTypeLib.Point pt1 = (HybridShapeTypeLib.Point)Pts.ElementAt(i);
                        HybridShapeTypeLib.Point pt2 = (HybridShapeTypeLib.Point)Pts.ElementAt(j);

                        INFITF.Reference ref1 = prt.CreateReferenceFromGeometry(pt1);
                        INFITF.Reference ref2 = prt.CreateReferenceFromGeometry(pt2);

                        HybridShapeTypeLib.Line lin = hfac.AddNewLinePtPt(ref1, ref2);
                        hbdy.AppendHybridShape(lin);
                    }
                }
                prt.Update();
            }
            catch (Exception)
            {
                MessageBox.Show("선택된 정보가 없습니다.");
                return;
            }
        }
예제 #3
0
 private MECMOD.Constraint createCnst(Part prt, Sketch skt, CatConstraintType cnstType, INFITF.AnyObject ob1, INFITF.AnyObject ob2)
 {
     INFITF.Reference  ref1 = prt.CreateReferenceFromGeometry(ob1);
     INFITF.Reference  ref2 = prt.CreateReferenceFromGeometry(ob2);
     MECMOD.Constraint cnst = skt.Constraints.AddBiEltCst(cnstType, ref1, ref2);
     return(cnst);
 }
예제 #4
0
        //create3Dline--------------------------------------------
        private void button5_Click(object sender, EventArgs e)
        {
            // object[] HpCrd1 = new object[3];
            // object[] HpCrd2 = new object[3];

            try
            {
                sel           = catia.ActiveDocument.Selection;
                HyShpPtCoord1 = (HybridShapeTypeLib.Point)sel.FindObject("CATIAHybridShapePoint");
                //sel = catia.ActiveDocument.Selection;
                HyShpPtCoord2 = (HybridShapeTypeLib.Point)sel.FindObject("CATIAHybridShapePoint");

                //HyShpPtCoord1.GetCoordinates(HpCrd1);
                //HyShpPtCoord1.GetCoordinates(HpCrd2);

                PartDocument       prtDoc = (PartDocument)catia.ActiveDocument;
                Part               prt    = prtDoc.Part;
                HybridBody         hbdy   = prt.HybridBodies.Item(1);
                HybridShapeFactory hfac   = (HybridShapeFactory)prt.HybridShapeFactory;

                INFITF.Reference ref1 = prt.CreateReferenceFromGeometry(HyShpPtCoord1);
                INFITF.Reference ref2 = prt.CreateReferenceFromGeometry(HyShpPtCoord2);

                HybridShapeTypeLib.Line lin = hfac.AddNewLinePtPt(ref1, ref2);
                hbdy.AppendHybridShape(lin);

                prt.Update();
            }
            catch (Exception)
            {
                MessageBox.Show("선택된 정보가 없습니다.");
                return;
            }
        }
예제 #5
0
        public INFITF.Reference GetCATIASketchReference(TransCAD.IStdSketchFeature tSketch)
        {
            INFITF.Reference cRef     = null;
            string           tRefName = tSketch.SketchPlane.ReferenceeName;

            if (tSketch.SketchPlane.Type == TransCAD.ReferenceType.ExplicitModelObject) // 평면인 경우
            {
                if (tRefName == "XYPlane")
                {
                    cRef = (INFITF.Reference)PartManager.cOriginalElements.PlaneXY;
                }
                else if (tRefName == "YZPlane")
                {
                    cRef = (INFITF.Reference)PartManager.cOriginalElements.PlaneYZ;
                }
                else if (tRefName == "ZXPlane")
                {
                    cRef = (INFITF.Reference)PartManager.cOriginalElements.PlaneZX;
                }
                else
                {
                    // DatumPlaneOffset
                }
            }
            else if (tSketch.SketchPlane.Type == TransCAD.ReferenceType.Brep) // B-rep 면인 경우
            {
                string cRefName = GetCATIANameFromTransCADName(tRefName);

                cRef = PartManager.cPart.CreateReferenceFromName(cRefName);
            }

            return(cRef);
        }
예제 #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            INFITF.Selection Sel;
            Sel = Catia.ActiveDocument.Selection;

            object[] inputObjectType = { "Point" };
            string   Status;

            Sel.Clear();
            Status = Sel.SelectElement2(inputObjectType, "Select an End Point", false);

            if (Status != "Normal")
            {
                label1.Text = "취소됨";
                return;
            }

            if (Sel.Count < 1)
            {
                label1.Text = "선택했나";
                return;
            }

            INFITF.SelectedElement SelItem;
            SelItem = Sel.Item(1);

            PtEnd = Sel.Item(1).Reference;
        }
예제 #7
0
        // CreateCnst overloading-------------
        private static Constraint CreateCnst(Part prt, Sketch skt, CatConstraintType cntype, INFITF.AnyObject ob)
        {
            INFITF.Reference r   = prt.CreateReferenceFromGeometry(ob);
            Constraint       cnt = skt.Constraints.AddMonoEltCst(cntype, r); //1객체를 구속시킨다.

            return(cnt);
        }
        // Post
        public override void TranslateT2C(TransCAD.IFeature tFeature)
        {
            TransCAD.IStdSolidFilletConstantFeature tFillet = (TransCAD.IStdSolidFilletConstantFeature)tFeature;

            double radius = tFillet.Radius;

            TransCAD.PropagationType propagation = tFillet.Propagation;

            PARTITF.ConstRadEdgeFillet cFillet = PartManager.cShapeFactory.AddNewEdgeFilletWithConstantRadius(null, PARTITF.CatFilletEdgePropagation.catMinimalFilletEdgePropagation, radius);

            IEnumerator edges = tFillet.FilletEdges.GetEnumerator();

            while (edges.MoveNext())
            {
                TransCAD.Reference edge = (TransCAD.Reference)edges.Current;

                string           cRefName = PartManager.ReferenceManager.GetCATIANameFromTransCADName(edge.ReferenceeName);
                INFITF.Reference cRef     = PartManager.cPart.CreateReferenceFromBRepName(cRefName, PartManager.GetRecentFeature());

                cFillet.AddObjectToFillet(cRef);
            }

            if (propagation == TransCAD.PropagationType.Tangency)
            {
                cFillet.EdgePropagation = PARTITF.CatFilletEdgePropagation.catTangencyFilletEdgePropagation;
            }

            PartManager.cPart.UpdateObject(cFillet);
            PartManager.ReferenceManager.NameMap.Add(tFillet.Name, cFillet.get_Name());
        }
예제 #9
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();
        }
예제 #10
0
        private INFITF.Reference GetReferencePlane(PARTITF.RectPattern cRectPattern, double[] firstDir, double[] secondDir)
        {
            INFITF.Reference refPlane = null;

            // XY 평면
            if ((Math.Abs(firstDir[0]) == 1.0 && Math.Abs(secondDir[1]) == 1.0) ||
                (Math.Abs(firstDir[1]) == 1.0 && Math.Abs(secondDir[0]) == 1.0))
            {
                refPlane = (INFITF.Reference)PartManager.cOriginalElements.PlaneXY;

                if (firstDir[0] < 0.0 || firstDir[1] < 0.0)
                {
                    cRectPattern.FirstOrientation = false;
                }

                if (secondDir[1] < 0.0 || secondDir[0] < 0.0)
                {
                    cRectPattern.SecondOrientation = false;
                }
            }
            // YZ 평면
            else if ((Math.Abs(firstDir[1]) == 1.0 && Math.Abs(secondDir[2]) == 1.0) ||
                     (Math.Abs(firstDir[2]) == 1.0 && Math.Abs(secondDir[1]) == 1.0))
            {
                refPlane = (INFITF.Reference)PartManager.cOriginalElements.PlaneYZ;

                if (firstDir[1] < 0.0 || firstDir[2] < 0.0)
                {
                    cRectPattern.FirstOrientation = false;
                }

                if (secondDir[2] < 0.0 || secondDir[1] < 0.0)
                {
                    cRectPattern.SecondOrientation = false;
                }
            }
            // ZX 평면
            else if ((Math.Abs(firstDir[2]) == 1.0 && Math.Abs(secondDir[0]) == 1.0) ||
                     (Math.Abs(firstDir[0]) == 1.0 && Math.Abs(secondDir[2]) == 1.0))
            {
                refPlane = (INFITF.Reference)PartManager.cOriginalElements.PlaneZX;

                if (firstDir[2] < 0.0 || firstDir[0] < 0.0)
                {
                    cRectPattern.FirstOrientation = false;
                }

                if (secondDir[0] < 0.0 || secondDir[2] < 0.0)
                {
                    cRectPattern.SecondOrientation = false;
                }
            }
            // 기타 경우. 고려 필요
            else
            {
            }

            return(refPlane);
        }
예제 #11
0
        //구속조건을 주는 method--------------------------------------------
        private static Constraint CreateCnst(Part prt, Sketch skt, CatConstraintType cntype, INFITF.AnyObject ob1, INFITF.AnyObject ob2)
        {
            INFITF.Reference r1  = prt.CreateReferenceFromGeometry(ob1);
            INFITF.Reference r2  = prt.CreateReferenceFromGeometry(ob2);
            Constraint       cnt = skt.Constraints.AddBiEltCst(cntype, r1, r2); //2객체 사이의 구속조건을 준다.

            return(cnt);
        }
예제 #12
0
        /// <param name="type">accepting params: {Cross, ZigZag}</param>
        public static void mainAction(grooveType type, double width, double depth, double edges, bool isolateKeyAuto, bool debugRastr, bool debugInflated)
        {
            //all try
            try {
                MainAction.isolateKeyAuto = isolateKeyAuto;
                MainAction.debugRastr     = debugRastr;
                MainAction.debugInflated  = debugInflated;

                MainAction.width = width;
                MainAction.depth = depth;
                MainAction.edges = edges;

                MainAction.type = type;

                try {
                    catiaInstance = (INFITF.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Catia.Application");
                } catch { return; }
                oPartDocument = (MECMOD.PartDocument)catiaInstance.ActiveDocument;

                MECMOD.PlanarFace oPlanarFace = null;
                INFITF.Reference  oReference  = null;

                List <PlanarfaceWithReference> selectedPlanarfaces = new List <PlanarfaceWithReference>();

                int selectionCount = Int32.Parse(oPartDocument.Selection.Count2.ToString());
                if (selectionCount >= 1)
                {
                    for (int i = 1; i <= selectionCount; i++)
                    {
                        try {
                            oPlanarFace = (MECMOD.PlanarFace)oPartDocument.Selection.Item2(i).Value;
                            oReference  = (INFITF.Reference)oPartDocument.Selection.Item2(i).Value;
                            selectedPlanarfaces.Add(new PlanarfaceWithReference(oPlanarFace, oReference));
                        } catch {  }
                    }
                }

                if (selectedPlanarfaces.Count >= 1)
                {
                    foreach (PlanarfaceWithReference cpl in selectedPlanarfaces)
                    {
                        action(cpl);
                    }
                }
                else
                {
                    MainForm.myForm.Activate();
                    MessageBox.Show("First select one or more planar faces!");
                    return;
                }

                //all catch
            } catch {}
        }
예제 #13
0
        private INFITF.Reference GetTargetFace(string tFaceName)
        {
            string targetFeatureName = tFaceName.Remove(tFaceName.IndexOf(","));

            MECMOD.Shape targetFeature = PartManager.cShapes.Item(PartManager.ReferenceManager.NameMap[targetFeatureName]);

            string targetFaceName = PartManager.ReferenceManager.GetCATIANameFromTransCADNameForHole(tFaceName);

            INFITF.Reference targetFace = PartManager.cPart.CreateReferenceFromBRepName(targetFaceName, targetFeature);

            return(targetFace);
        }
예제 #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            //List<Pnt> pList = new List<Pnt>();
            List <HybridShapeTypeLib.Point> pList = new List <HybridShapeTypeLib.Point>();

            //prtDoc = (PartDocument)catia.Documents.Item(1);
            prtDoc = (PartDocument)catia.Documents.Add("Part");

            Part         prt   = prtDoc.Part;
            HybridBodies hbdys = prt.HybridBodies;
            HybridBody   hbdy  = hbdys.Add();

            hbdy.set_Name("saori");
            HybridShapeFactory hsFac = (HybridShapeFactory)prt.HybridShapeFactory;

            //string Line = textBox1.Text;
            string lin = "";

            if (textBox1.Text == "")
            {
                MessageBox.Show("좌표를 입력해주새요");
                return;
            }

            for (int i = 0; i < textBox1.Lines.Length; i++)
            {
                lin = textBox1.Lines[i];
                string[] token = lin.Split(',');
                int      x     = int.Parse(token[0]);
                int      y     = int.Parse(token[1]);
                int      z     = int.Parse(token[2]);
                // pList.Add(new Pnt(x, y, z));
                pList.Add(hsFac.AddNewPointCoord(x, y, z));
                HybridShapeTypeLib.Point p = hsFac.AddNewPointCoord(x, y, z); //create a point
                hbdy.AppendHybridShape(p);
            }
            //create points and spline
            HybridShapeSpline splin = hsFac.AddNewSpline();

            foreach (HybridShapeTypeLib.Point p in pList)
            {
                INFITF.Reference r = prt.CreateReferenceFromGeometry(p);
                // hsFac.AddNewPointDatum(r);
                //hbdy.AppendHybridShape(p);
                splin.AddPoint(r);
            }
            hbdy.AppendHybridShape(splin);
            prt.Update();
        }
예제 #15
0
        //select an end point
        private void button2_Click(object sender, EventArgs e)
        {
            //obj = null;
            sel = catia.ActiveDocument.Selection;
            sel.Clear();
            object[] inputObjType = { "Point" };
            string   status       = sel.SelectElement2(inputObjType, "Select a end point", false);

            if (status != "Normal" || sel.Count < 1)
            {
                MessageBox.Show("Select a start point.");
                return;
            }
            ptEnd = sel.Item(1).Reference;
        }
예제 #16
0
        // Post
        public override void TranslateT2C(TransCAD.IFeature tFeature)
        {
            TransCAD.IStdSolidOperatePatternRectangularFeature tRectPattern = (TransCAD.IStdSolidOperatePatternRectangularFeature)tFeature;

            double[] colDir = new double[3];
            double[] rowDir = new double[3];

            tRectPattern.ColumnDirection(out colDir[0], out colDir[1], out colDir[2]);
            tRectPattern.RowDirection(out rowDir[0], out rowDir[1], out rowDir[2]);

            int    colInstance = tRectPattern.ColumnNumber;
            double colSpacing  = tRectPattern.ColumnSpacing;
            int    rowInstance = tRectPattern.RowNumber;
            double rowSpacing  = tRectPattern.RowSpacing;

            PARTITF.RectPattern cRectPattern = PartManager.cShapeFactory.AddNewRectPattern(null, 2, 1, 20.0, 20.0, 1, 1, null, null, true, true, 0.0);

            IEnumerator tTargetFeatures = tRectPattern.TargetFeatures.GetEnumerator();

            while (tTargetFeatures.MoveNext())
            {
                TransCAD.Reference tTargetFeature = (TransCAD.Reference)tTargetFeatures.Current;

                cRectPattern.ItemToCopy = PartManager.cShapes.Item(PartManager.ReferenceManager.NameMap[tTargetFeature.ReferenceeName]);
            }

            cRectPattern.FirstRectangularPatternParameters  = PARTITF.CatRectangularPatternParameters.catInstancesandSpacing;
            cRectPattern.SecondRectangularPatternParameters = PARTITF.CatRectangularPatternParameters.catInstancesandSpacing;

            INFITF.Reference referencePlane = GetReferencePlane(cRectPattern, colDir, rowDir);
            cRectPattern.SetFirstDirection(referencePlane);
            cRectPattern.SetSecondDirection(referencePlane);

            cRectPattern.FirstDirectionRepartition.InstancesCount.Value = colInstance;
            cRectPattern.FirstDirectionRepartition.Spacing.Value        = colSpacing;

            cRectPattern.SecondDirectionRepartition.InstancesCount.Value = rowInstance;
            cRectPattern.SecondDirectionRepartition.Spacing.Value        = rowSpacing;

            PartManager.cPart.UpdateObject(cRectPattern);
            PartManager.ReferenceManager.NameMap.Add(tRectPattern.Name, cRectPattern.get_Name());
        }
예제 #17
0
        // Post
        public override void TranslateT2C(TransCAD.IFeature tFeature)
        {
            TransCAD.IStdSolidProtrusionSweepFeature proSweep = (TransCAD.IStdSolidProtrusionSweepFeature)tFeature;

            FeatureSketch ProfileSketch = new FeatureSketch(PartManager);

            ProfileSketch.TranslateT2C(PartManager.GetFeatureFromReference(proSweep.ProfileSketch));
            INFITF.Reference profile = ProfileSketch.cReference;

            FeatureSketch GuideSketch = new FeatureSketch(PartManager);

            GuideSketch.TranslateT2C(PartManager.GetFeatureFromReference(proSweep.GuideCurve));
            INFITF.Reference guide = GuideSketch.cReference;

            PARTITF.Rib cRib = PartManager.cShapeFactory.AddNewRibFromRef(null, null);
            cRib.SetProfileElement(profile);
            cRib.CenterCurveElement = guide;

            PartManager.cPart.UpdateObject(cRib);
            PartManager.ReferenceManager.NameMap.Add(proSweep.Name, cRib.get_Name());
        }
예제 #18
0
        // Post
        public override void TranslateT2C(TransCAD.IFeature tFeature)
        {
            TransCAD.IStdSolidOperatePatternCircularFeature tCircPattern = (TransCAD.IStdSolidOperatePatternCircularFeature)tFeature;

            double[] center = new double[3];
            double[] axis   = new double[3];

            tCircPattern.CenterAxis(out center[0], out center[1], out center[2], out axis[0], out axis[1], out axis[2]);

            int    angInstance = tCircPattern.AngleNumber;
            double angSpacing  = tCircPattern.AngleIncrement;
            int    radInstance = tCircPattern.RadialNumber;
            double radSpacing  = tCircPattern.RadialSpacing;

            PARTITF.CircPattern cCircPattern = PartManager.cShapeFactory.AddNewCircPattern(null, 1, 2, 20.0, 45.0, 1, 1, null, null, true, 0.0, true);

            IEnumerator tTargetFeatures = tCircPattern.TargetFeatures.GetEnumerator();

            while (tTargetFeatures.MoveNext())
            {
                TransCAD.Reference tTargetFeature = (TransCAD.Reference)tTargetFeatures.Current;

                cCircPattern.ItemToCopy = PartManager.cShapes.Item(PartManager.ReferenceManager.NameMap[tTargetFeature.ReferenceeName]);
            }

            cCircPattern.CircularPatternParameters = PARTITF.CatCircularPatternParameters.catInstancesandAngularSpacing;

            INFITF.Reference rotationAxis = GetRotationAxis(cCircPattern, center, axis);
            cCircPattern.SetRotationAxis(rotationAxis);

            cCircPattern.AngularRepartition.InstancesCount.Value = angInstance;
            cCircPattern.AngularRepartition.AngularSpacing.Value = angSpacing;

            cCircPattern.RadialRepartition.InstancesCount.Value = radInstance;
            cCircPattern.RadialRepartition.Spacing.Value        = radSpacing;

            PartManager.cPart.UpdateObject(cCircPattern);
            PartManager.ReferenceManager.NameMap.Add(tCircPattern.Name, cCircPattern.get_Name());
        }
예제 #19
0
        private INFITF.Reference GetRotationAxis(PARTITF.CircPattern cCircPattern, double[] center, double[] axis)
        {
            INFITF.Reference rotAxis = null;

            if (Math.Abs(axis[0]) == 1.0)
            {
                rotAxis = (INFITF.Reference)PartManager.cOriginalElements.PlaneYZ;

                if (axis[0] == -1.0)
                {
                    cCircPattern.RotationOrientation = false;
                }
            }
            else if (Math.Abs(axis[1]) == 1.0)
            {
                rotAxis = (INFITF.Reference)PartManager.cOriginalElements.PlaneZX;

                if (axis[1] == -1.0)
                {
                    cCircPattern.RotationOrientation = false;
                }
            }
            else if (Math.Abs(axis[2]) == 1.0)
            {
                rotAxis = (INFITF.Reference)PartManager.cOriginalElements.PlaneXY;

                if (axis[2] == -1.0)
                {
                    cCircPattern.RotationOrientation = false;
                }
            }
            else
            {
            }

            return(rotAxis);
        }
예제 #20
0
        static void Main(string[] args)
        {
            INFITF.Application catia;
            try
            {
                catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application");
            }
            catch (Exception)
            {
                catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
            }
            catia.Visible = true;

            PartDocument prtDoc = (PartDocument)catia.Documents.Add("Part");
            Part         prt1   = prtDoc.Part;
            //Part prt2 = prtDoc.Part;
            //Part prt3 = prtDoc.Part;

            //prt1 rectangre
            Bodies   bdys1 = prt1.Bodies;
            Body     bdy1  = bdys1.Add();
            Sketches skts1 = bdy1.Sketches;

            INFITF.Reference xyPln = (INFITF.Reference)prt1.OriginElements.PlaneXY;
            Sketch           skt1  = skts1.Add(xyPln);
            Factory2D        fac1  = skt1.OpenEdition();

            Point2D p1 = fac1.CreatePoint(0, 0);
            Point2D p2 = fac1.CreatePoint(10, 0);
            Point2D p3 = fac1.CreatePoint(10, 10);
            Point2D p4 = fac1.CreatePoint(0, 10);

            Line2D lin1 = CreateLine(fac1, p1, p2);
            Line2D lin2 = CreateLine(fac1, p2, p3);
            Line2D lin3 = CreateLine(fac1, p3, p4);
            Line2D lin4 = CreateLine(fac1, p4, p1);



            skt1.CloseEdition();
            //part2 circle
            //Bodies bdys2 = prt1.Bodies;
            Body bdy2 = bdys1.Add();
            //Sketches skts2 = bdy2.Sketches;
            //INFITF.Reference xyPln = (INFITF.Reference)prt2.OriginElements.PlaneXY;
            Sketch skt2 = skts1.Add(xyPln);

            fac1 = skt2.OpenEdition();



            skt2.CloseEdition();
            //part3 triangle
            //Bodies bdys3 = prt1.Bodies;
            Body bdy3 = bdys1.Add();
            //Sketches skts1 = bdy1.Sketches;
            //INFITF.Reference xyPln = (INFITF.Reference)prt1.OriginElements.PlaneXY;
            Sketch skt3 = skts1.Add(xyPln);

            fac1 = skt3.OpenEdition();



            skt3.CloseEdition();
        }
 public PlanarfaceWithReference(MECMOD.PlanarFace oPlanarFace,INFITF.Reference oReference)
 {
     this.oPlanarFace = oPlanarFace;
     this.oReference = oReference;
 }
예제 #22
0
        // Post
        public void TranslateT2C(TransCAD.IFeature tFeature)
        {
            TransCAD.IStdSketchFeature tSketch = (TransCAD.IStdSketchFeature)tFeature;

            string sketchName = tSketch.Name;

            TransCAD.IStdSketchGeometries tGeoms = tSketch.Geometries;

            double[] coords  = new double[9];
            object[] tCoords = new object[9];

            tSketch.GetCoordinateSystem(out coords[0], out coords[1], out coords[2],
                                        out coords[3], out coords[4], out coords[5],
                                        out coords[6], out coords[7], out coords[8]);

            for (int i = 0; i < 9; ++i)
            {
                tCoords[i] = coords[i];
            }

            INFITF.Reference cSktReference = PartManager.ReferenceManager.GetCATIASketchReference(tSketch);
            MECMOD.Sketch    cSketch       = PartManager.cSketches.Add(cSktReference);
            cSketch.SetAbsoluteAxisData(tCoords);

            cFactory = cSketch.OpenEdition();

            // 스케치 로컬 좌표 축 설정
            MECMOD.GeometricElement axis   = cSketch.GeometricElements.Item("AbsoluteAxis");
            INFITF.CATBaseDispatch  localX = axis.GetItem("HDirection");
            MECMOD.Line2D           locX   = (MECMOD.Line2D)localX;
            locX.ReportName = ++cReportName;

            INFITF.CATBaseDispatch localY = axis.GetItem("VDirection");
            MECMOD.Line2D          locY   = (MECMOD.Line2D)localY;
            locX.ReportName = ++cReportName;

            IEnumerator tGeomList = tGeoms.GetEnumerator();

            while (tGeomList.MoveNext())
            {
                TransCAD.IStdSketchGeometry tGeom = (TransCAD.IStdSketchGeometry)tGeomList.Current;

                if (tGeom.Type == TransCAD.StdSketchGeometryType.Line ||
                    tGeom.Type == TransCAD.StdSketchGeometryType.Centerline)
                {
                    SketchLine2D line2D = new SketchLine2D(this);
                    line2D.TranslateT2C(tGeom);

                    if (tGeom.Type == TransCAD.StdSketchGeometryType.Centerline)
                    {
                        cSketch.CenterLine = cCenterLine;
                    }
                }
                else if (tGeom.Type == TransCAD.StdSketchGeometryType.Circle ||
                         tGeom.Type == TransCAD.StdSketchGeometryType.CircularArc)
                {
                    SketchCircle2D circle2D = new SketchCircle2D(this);
                    circle2D.TranslateT2C(tGeom);
                }
            }

            cSketch.CloseEdition();

            cReference = PartManager.cPart.CreateReferenceFromObject(cSketch);

            PartManager.cPart.InWorkObject = cSketch;
            PartManager.cPart.UpdateObject(cSketch);

            PartManager.ReferenceManager.NameMap.Add(tSketch.Name, cSketch.get_Name());
        }
예제 #23
0
        private void button1_Click(object sender, EventArgs e)
        {
            INFITF.Application catia; //add the reference - catia v5 infiit interface...

            try
            {
                //열려 있는 catia가져오기
                catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application");
            }
            catch (Exception)
            {
                //catia 실행하기
                catia         = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
                catia.Visible = true;
            }

            MECMOD.PartDocument prtDoc = (MECMOD.PartDocument)catia.Documents.Add("Part");
            MECMOD.Part         prt    = prtDoc.Part;
            MECMOD.Bodies       bdys   = prt.Bodies;
            MECMOD.Body         bdy    = bdys.Add();
            MECMOD.Sketches     skts   = bdy.Sketches;

            INFITF.Reference xypln = (INFITF.Reference)prt.OriginElements.PlaneXY;
            Sketch           skt1  = skts.Add(xypln);

            Factory2D fac2d = skt1.OpenEdition();   //fac2d안에서 sketch가 이루어진다. fac2d cketch의 기능을 쓸수있다

            Point2D p1 = fac2d.CreatePoint(10, 10);
            Point2D p2 = fac2d.CreatePoint(10, 30);
            Point2D p3 = fac2d.CreatePoint(40, 30);
            Point2D p4 = fac2d.CreatePoint(40, 10);

            //method를 만들고 line생성
            Line2D lin1 = CreateLine(fac2d, p1, p2);
            Line2D lin2 = CreateLine(fac2d, p2, p3);
            Line2D lin3 = CreateLine(fac2d, p3, p4);
            Line2D lin4 = CreateLine(fac2d, p4, p1);

            CatConstraintType cnstDis = CatConstraintType.catCstTypeDistance;


            MECMOD.Constraint d1 = createCnst(prt, skt1, cnstDis, lin1, lin3);
            MECMOD.Constraint d2 = createCnst(prt, skt1, cnstDis, lin2, lin4);
            MECMOD.Constraint d3 = createCnst(prt, skt1, cnstDis, skt1.AbsoluteAxis.HorizontalReference, lin4);
            MECMOD.Constraint d4 = createCnst(prt, skt1, cnstDis, skt1.AbsoluteAxis.VerticalReference, lin1);

            /*
             * INFITF.Reference rline1 = prt.CreateReferenceFromGeometry(lin1);
             * INFITF.Reference rline2 = prt.CreateReferenceFromGeometry(lin2);
             * INFITF.Reference rline3 = prt.CreateReferenceFromGeometry(lin3);
             * INFITF.Reference rline4 = prt.CreateReferenceFromGeometry(lin4);
             * INFITF.Reference rlineH = prt.CreateReferenceFromGeometry(skt1.AbsoluteAxis.HorizontalReference);
             * INFITF.Reference rlineV = prt.CreateReferenceFromGeometry(skt1.AbsoluteAxis.VerticalReference);
             *
             * MECMOD.Constraint d1 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline1, rline3);
             * MECMOD.Constraint d2 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rline2, rline4);
             * MECMOD.Constraint d3 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineH, rline4);
             * MECMOD.Constraint d4 = skt1.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, rlineV, rline1);
             */
            skt1.CloseEdition();

            //create a circlr
            Sketch    skt2   = skts.Add(xypln);
            Factory2D fac2d1 = skt2.OpenEdition();

            //fac2d = skt2.OpenEdition();   //이렇게 함녀 된다.

            INFITF.Reference H = prt.CreateReferenceFromGeometry(skt2.AbsoluteAxis.HorizontalReference);
            INFITF.Reference V = prt.CreateReferenceFromGeometry(skt2.AbsoluteAxis.VerticalReference);

            Circle2D c = fac2d1.CreateClosedCircle(40, 30, 10);

            c.CenterPoint = p3;
            // MECMOD.Constraint orPtH = skt2.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance,H,(INFITF.Reference)c);
            //MECMOD.Constraint orPtV = skt2.Constraints.AddBiEltCst(CatConstraintType.catCstTypeDistance, V, (INFITF.Reference)c);
            MECMOD.Constraint r = skt2.Constraints.AddMonoEltCst(CatConstraintType.catCstTypeRadius, (INFITF.Reference)c);

            skt2.CloseEdition();

            ShapeFactory ShpFac = (ShapeFactory)prt.ShapeFactory;
            //pad
            Pad pad = ShpFac.AddNewPad(skt1, 20);

            //poket
            Pocket pock = ShpFac.AddNewPocket(skt2, 20);

            pock.DirectionOrientation = CatPrismOrientation.catRegularOrientation;

            prt.Update();
        }
예제 #24
0
        static void Main(string[] args)
        {
            INFITF.Application catia;
            try
            {
                catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application");
            }
            catch (Exception)
            {
                catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
            }
            catia.Visible = true;

            PartDocument prtDoc   = (PartDocument)catia.Documents.Add("Part");
            Part         prt      = prtDoc.Part;
            Bodies       bdys     = prt.Bodies;
            Body         PartBody = bdys.Item(1);

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

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

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

            skt.CloseEdition();

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

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

            fac2d = skt2.OpenEdition();

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

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

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

            fac2d = skt3.OpenEdition();

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

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

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

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

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

            prt.Update();
        }
예제 #25
0
        // Post
        public override void TranslateT2C(TransCAD.IFeature tFeature)
        {
            double diameter     = 0.0;
            double depth        = 0.0;
            double bottomAngle  = 180.0;
            double headDiameter = 0.0;
            double headAngle    = 0.0;
            double headDepth    = 0.0;

            double[] org = new double[3];

            PARTITF.Hole cHole = null;

            if (tFeature.Type == TransCAD.FeatureType.StdSolidHoleSimpleFeature)
            {
                TransCAD.IStdSolidHoleSimpleFeature tHoleSimple = (TransCAD.IStdSolidHoleSimpleFeature)tFeature;
                tHoleSimple.CenterPoint(out org[0], out org[1], out org[2]);
                depth    = tHoleSimple.Depth;
                diameter = tHoleSimple.Radius * 2;
                INFITF.Reference targetFace = GetTargetFace(tHoleSimple.TargetFace.ReferenceeName);

                cHole      = PartManager.cShapeFactory.AddNewHole(targetFace, 10.0);
                cHole.Type = PARTITF.CatHoleType.catSimpleHole;
                cHole.SetOrigin(org[0], org[1], org[2]);
                cHole.BottomLimit.Dimension.Value = depth;
                cHole.Diameter.Value = diameter;

                PartManager.ReferenceManager.NameMap.Add(tHoleSimple.Name, cHole.get_Name());
            }
            else if (tFeature.Type == TransCAD.FeatureType.StdSolidHoleCounterboredFeature)
            {
                TransCAD.StdSolidHoleCounterboredFeature tHoleCounterbored = (TransCAD.StdSolidHoleCounterboredFeature)tFeature;
                tHoleCounterbored.CenterPoint(out org[0], out org[1], out org[2]);
                headDepth    = tHoleCounterbored.StartDepth;
                headDiameter = tHoleCounterbored.StartRadius * 2;
                depth        = tHoleCounterbored.EndDepth + headDepth;
                diameter     = tHoleCounterbored.EndRadius * 2;
                bottomAngle  = tHoleCounterbored.Angle;
                INFITF.Reference targetFace = GetTargetFace(tHoleCounterbored.TargetFace.ReferenceeName);

                cHole      = PartManager.cShapeFactory.AddNewHole(targetFace, 10.0);
                cHole.Type = PARTITF.CatHoleType.catCounterboredHole;
                cHole.SetOrigin(org[0], org[1], org[2]);
                cHole.HeadDepth.Value             = headDepth;
                cHole.HeadDiameter.Value          = headDiameter;
                cHole.BottomLimit.Dimension.Value = depth;
                cHole.Diameter.Value = diameter;

                PartManager.ReferenceManager.NameMap.Add(tHoleCounterbored.Name, cHole.get_Name());
            }
            else if (tFeature.Type == TransCAD.FeatureType.StdSolidHoleCountersunkFeature)
            {
                TransCAD.IStdSolidHoleCountersunkFeature tHoleCountersunk = (TransCAD.IStdSolidHoleCountersunkFeature)tFeature;
                tHoleCountersunk.CenterPoint(out org[0], out org[1], out org[2]);
                headAngle    = tHoleCountersunk.SinkAngle;
                headDiameter = tHoleCountersunk.SinkRadius * 2;
                depth        = tHoleCountersunk.Depth;
                diameter     = tHoleCountersunk.Radius * 2;
                headDepth    = 0.5 * (headDiameter - diameter) / Math.Tan(0.5 * headAngle * Math.PI / 180);

                bottomAngle = tHoleCountersunk.BottomAngle;
                INFITF.Reference targetFace = GetTargetFace(tHoleCountersunk.TargetFace.ReferenceeName);

                cHole                 = PartManager.cShapeFactory.AddNewHole(targetFace, 10.0);
                cHole.Type            = PARTITF.CatHoleType.catCountersunkHole;
                cHole.CounterSunkMode = PARTITF.CatCSHoleMode.catCSModeAngleDiameter;
                cHole.SetOrigin(org[0], org[1], org[2]);
                cHole.HeadAngle.Value             = headAngle;
                cHole.HeadDepth.Value             = headDepth;
                cHole.BottomLimit.Dimension.Value = depth;
                cHole.Diameter.Value = diameter;

                PartManager.ReferenceManager.NameMap.Add(tHoleCountersunk.Name, cHole.get_Name());
            }

            if (bottomAngle != 180.0)
            {
                cHole.BottomType        = PARTITF.CatHoleBottomType.catVHoleBottom;
                cHole.BottomAngle.Value = bottomAngle;
            }

            PartManager.cPart.UpdateObject(cHole);
        }
        static void Main(string[] args)
        {
            INFITF.Application catia; //add the reference - catia v5 infiit interface...

            try
            {
                //열려 있는 catia가져오기
                catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application");
            }
            catch (Exception)
            {
                //catia 실행하기
                catia         = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
                catia.Visible = true;
            }

            MECMOD.PartDocument prtDoc = (MECMOD.PartDocument)catia.Documents.Add("Part");
            MECMOD.Part         prt    = prtDoc.Part;

            HybridBodies hybdys = prt.HybridBodies;
            HybridBody   hybdy  = hybdys.Add();
            HybridShapes hyshps = hybdy.HybridShapes;

            HybridShapeFactory hyshfac = (HybridShapeFactory)prt.HybridShapeFactory;

            Point p1 = hyshfac.AddNewPointCoord(10, 60, 30);
            Point p2 = hyshfac.AddNewPointCoord(70, 75, 35);
            Point p3 = hyshfac.AddNewPointCoord(100, 80, 30);

            Point p4 = hyshfac.AddNewPointCoord(100, 80, 40);
            Point p5 = hyshfac.AddNewPointCoord(95, 20, 45);
            Point p6 = hyshfac.AddNewPointCoord(100, 10, 50);

            INFITF.Reference r1 = prt.CreateReferenceFromGeometry(p1);
            INFITF.Reference r2 = prt.CreateReferenceFromGeometry(p2);
            INFITF.Reference r3 = prt.CreateReferenceFromGeometry(p3);
            INFITF.Reference r4 = prt.CreateReferenceFromGeometry(p4);
            INFITF.Reference r5 = prt.CreateReferenceFromGeometry(p5);
            INFITF.Reference r6 = prt.CreateReferenceFromGeometry(p6);

            HybridShapeSpline hyspl1 = hyshfac.AddNewSpline();
            HybridShapeSpline hyspl2 = hyshfac.AddNewSpline();


            hyspl1.AddPoint(r1);
            hyspl1.AddPoint(r2);
            hyspl1.AddPoint(r3);

            hyspl2.AddPoint(r4);
            hyspl2.AddPoint(r5);
            hyspl2.AddPoint(r6);

            hybdy.AppendHybridShape(hyspl1);
            hybdy.AppendHybridShape(hyspl2); //AppendHybridShape 만들고 바로 해야 된다

            INFITF.Reference rspl1 = prt.CreateReferenceFromGeometry(hyspl1);
            INFITF.Reference rspl2 = prt.CreateReferenceFromGeometry(hyspl2);

            HybridShapeSweepExplicit swp = hyshfac.AddNewSweepExplicit(rspl1, rspl2);

            hybdy.AppendHybridShape(swp);

            Point p = hyshfac.AddNewPointCoord(50, 30, 100);

            hybdy.AppendHybridShape(p);

            HybridShapeProject hsprjct = hyshfac.AddNewProject((INFITF.Reference)p, (INFITF.Reference)swp);



            prt.Update();
        }
예제 #27
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();
        }
 public PlanarfaceWithReference(MECMOD.PlanarFace oPlanarFace, INFITF.Reference oReference)
 {
     this.oPlanarFace = oPlanarFace;
     this.oReference  = oReference;
 }
예제 #29
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();
        }
예제 #30
0
        static void Main(string[] args)
        {
            INFITF.Application catia;
            try
            {
                catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application");
            }
            catch (Exception)
            {
                catia = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
            }
            catia.Visible = true;

            PartDocument prtdoc = (PartDocument)catia.Documents.Add("Part");
            Part         prt    = prtdoc.Part;

            HybridBodies       hbdys = prt.HybridBodies;
            HybridBody         hbdy  = hbdys.Add();
            HybridShapeFactory hsFac = (HybridShapeFactory)prt.HybridShapeFactory;

            Point p1 = hsFac.AddNewPointCoord(10, 60, 30);
            Point p2 = hsFac.AddNewPointCoord(70, 75, 35);
            Point p3 = hsFac.AddNewPointCoord(100, 80, 30);
            Point p4 = hsFac.AddNewPointCoord(100, 80, 40);
            Point p5 = hsFac.AddNewPointCoord(95, 20, 45);
            Point p6 = hsFac.AddNewPointCoord(100, 10, 50);

            INFITF.Reference r1 = prt.CreateReferenceFromGeometry(p1);
            INFITF.Reference r2 = prt.CreateReferenceFromGeometry(p2);
            INFITF.Reference r3 = prt.CreateReferenceFromGeometry(p3);
            INFITF.Reference r4 = prt.CreateReferenceFromGeometry(p4);
            INFITF.Reference r5 = prt.CreateReferenceFromGeometry(p5);
            INFITF.Reference r6 = prt.CreateReferenceFromGeometry(p6);

            HybridShapeSpline hspln1 = hsFac.AddNewSpline();
            HybridShapeSpline hspln2 = hsFac.AddNewSpline();

            hspln1.AddPoint(r1);
            hspln1.AddPoint(r2);
            hspln1.AddPoint(r3);

            hspln2.AddPoint(r4);
            hspln2.AddPoint(r5);
            hspln2.AddPoint(r6);

            hbdy.AppendHybridShape(hspln1);
            hbdy.AppendHybridShape(hspln2);

            INFITF.Reference rspl1 = prt.CreateReferenceFromGeometry(hspln1);
            INFITF.Reference rspl2 = prt.CreateReferenceFromGeometry(hspln2);

            HybridShapeSweepExplicit swp = hsFac.AddNewSweepExplicit(rspl1, rspl2);

            hbdy.AppendHybridShape(swp);

            Point p = hsFac.AddNewPointCoord(50, 30, 100);

            hbdy.AppendHybridShape(p);
            HybridShapeProject prjct = hsFac.AddNewProject((INFITF.Reference)p, (INFITF.Reference)swp);

            hbdy.AppendHybridShape(prjct);

            prt.Update();
        }