Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (PtStart == null)
            {
                return;
            }

            if (PtEnd == null)
            {
                return;
            }

            MECMOD.PartDocument PrtDoc = (MECMOD.PartDocument)Catia.ActiveDocument;
            MECMOD.Part         prt    = PrtDoc.Part;

            MECMOD.HybridBodies HBs = prt.HybridBodies;

            MECMOD.HybridBody HyBody = HBs.Add();

            HybridShapeTypeLib.HybridShapeFactory  HSFac    = (HybridShapeTypeLib.HybridShapeFactory)prt.HybridShapeFactory;
            HybridShapeTypeLib.HybridShapeLinePtPt Lineptpt = null;
            Lineptpt = HSFac.AddNewLinePtPt((INFITF.Reference)PtStart, (INFITF.Reference)PtEnd);

            HyBody.AppendHybridShape(Lineptpt);
            prt.Update();
        }
Exemplo n.º 2
0
 public void UninitializeCATIA()
 {
     cPart               = null;
     cBodies             = null;
     cCurrentBody        = null;
     cShapes             = null;
     cFactory            = null;
     cShapeFactory       = null;
     cHybridShapeFactory = null;
     cSketches           = null;
     cOriginalElements   = null;
 }
Exemplo n.º 3
0
        //// CATIA 관련 함수
        public bool InitializeCATIA(string filePath, int mode)
        {
            try
            {
                cApp = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application");
            }
            catch
            {
                cApp = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
            }

            if (cApp == null)
            {
                return(false);
            }

            cDocs = cApp.Documents;

            if (mode == 0)
            {
                cPartDoc = (MECMOD.PartDocument)cDocs.Read(filePath);
            }
            else if (mode == 1)
            {
                cPartDoc = (MECMOD.PartDocument)cDocs.Add("Part");
            }

            cApp.Visible = true;

            cPart   = cPartDoc.Part;
            cBodies = cPart.Bodies;

            cFactory            = cPart.ShapeFactory;
            cShapeFactory       = (PARTITF.ShapeFactory)cFactory;
            cHybridShapeFactory = (HybridShapeTypeLib.HybridShapeFactory)cPart.HybridShapeFactory;

            cCurrentBody      = cBodies.Item(1);
            cShapes           = cCurrentBody.Shapes;
            cSketches         = cCurrentBody.Sketches;
            cOriginalElements = cPart.OriginElements;

            if (ReferenceManager == null)
            {
                ReferenceManager = new Reference(this);
            }

            return(true);
        }