Пример #1
0
        //// TransCAD 관련 함수
        public bool InitializeTransCAD()
        {
            try
            {
                tApp = (TransCAD.Application)Marshal.GetActiveObject("TransCAD.Application");
            }
            catch
            {
                tApp = (TransCAD.Application)Activator.CreateInstance(Type.GetTypeFromProgID("TransCAD.Application"));
            }
            if (tApp == null)
            {
                return(false);
            }

            tDocs     = tApp.Documents;
            tAssemDoc = tDocs.AddAssemDocument();
            tAssem    = tAssemDoc.Assem;

            tComp = tAssem.CreateComponent();
            tComp.set_Name("Components1");

            tAssem.AddComponent(tComp);
            tConstraints = tAssem.Constraints;

            tApp.Visible = true;
            return(true);
        }
Пример #2
0
 public void UninitializeTransCAD()
 {
     tApp      = null;
     tDocs     = null;
     tPartDoc  = null;
     tPart     = null;
     tAssemDoc = null;
     tFeatures = null;
 }
Пример #3
0
 public void UninitializeTransCAD()
 {
     tApp         = null;
     tDocs        = null;
     tAssemDoc    = null;
     tAssem       = null;
     tComp        = null;
     tConstraints = null;
 }
Пример #4
0
        //// TransCAD 관련 함수
        public bool InitializeTransCAD(int mode)
        {
            try
            {
                tApp = (TransCAD.Application)Marshal.GetActiveObject("TransCAD.Application");
            }
            catch
            {
                tApp = (TransCAD.Application)Activator.CreateInstance(Type.GetTypeFromProgID("TransCAD.Application"));
            }

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

            tDocs = tApp.Documents;


            if (mode == 0) //assembly Pre 일때 사용
            {
                tAssemDoc = tDocs.AddAssemDocument();
            }
            else if (mode == 1) //assembly Post 일때 사용
            {
                tAssemDoc = (TransCAD.AssemDocument)tApp.ActiveDocument;
            }
            //_spAssemDoc = g_spApplication->ActiveDocument; C++

            /* 어셈블리 구조 추가 코드 Preprossor 일때 보통 적용할 수 잇을뜻.
             * tAssemDoc = tDocs.AddAssemDocument();
             * TransCAD.Assem tAssem = tAssemDoc.Assem;
             * TransCAD.Component tComp = tAssem.CreateComponent();
             * tComp.set_Name("Comp1");
             *
             * tPart = tAssem.CreatePart();
             * tPart.set_Name("Part1");
             *
             * tComp.AddPart(tPart);
             * tAssem.AddComponent(tComp);
             */


            //if (ReferenceManager == null)
            //    ReferenceManager = new Reference(this);

            //tAssemDoc.Update();

            return(true);
        }
Пример #5
0
        ////

        //// TransCAD 관련 함수
        public bool InitializeTransCAD(int mode)
        {
            try
            {
                tApp = (TransCAD.Application)Marshal.GetActiveObject("TransCAD.Application");
            }
            catch
            {
                tApp = (TransCAD.Application)Activator.CreateInstance(Type.GetTypeFromProgID("TransCAD.Application"));
            }

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

            tDocs = tApp.Documents;

            if (mode == 0)  //pre일때 사용 PartDocument 추가
            {
                tPartDoc = tDocs.AddPartDocument();
            }
            else if (mode == 1) //post일때 사용 이미 열려있는 것을 Active
            {
                tPartDoc = (TransCAD.PartDocument)tApp.ActiveDocument;
            }
            else if (mode == 2) //Assembly document에서 part 번역을 위한 initialization
            {
                tAssemDoc         = (TransCAD.AssemDocument)tApp.ActiveDocument;
                isSubAssemblyPart = true;
                return(true);
            }



            tApp.Visible = true;

            tPart     = tPartDoc.Part;
            tFeatures = tPart.Features;

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

            //tAssemDoc.Update();

            return(true);
        }
Пример #6
0
        public void loadAssemblyInfo()
        {
            tAssemDoc = (TransCAD.AssemDocument)tApp.ActiveDocument;
            tAssem    = tAssemDoc.Assem;
            //Count Component Number
            compCount = tAssem.GetSize();
            compName  = new string[compCount];
            for (int i = 0; i < compCount; i++)
            {
                TransCAD.Component tComp = tAssem.GetComponent(i);
                compName[i] = tComp.get_Name();
                Console.WriteLine("Name of Component[ " + i + " ] : " + tComp.get_Name());

                //Count Part Number in Component
                partCount = tComp.GetSize();
                partname  = new string[partCount];
                if (compName[i] == "Default SubAssembly")
                {
                    continue;
                }
                tcad_PartList = new TransCAD.Part[partCount];
                partFileName  = new string[partCount];
                NXObject[] nxGeom = new NXObject[partCount];
                for (int j = 0; j < partCount; j++)
                {
                    TransCAD.Part tPart = tComp.GetPart(j);
                    partname[j]      = tPart.Name;
                    tcad_PartList[j] = tPart;
                    int    facecount = tPart.Solid.Faces.Count;
                    string facenm    = tPart.Solid.Faces[1].Name;
                    Console.WriteLine(facenm);
                    Console.WriteLine(" Name of Part[ " + j + " ] : " + tPart.Name);
                    partFileName[j] = tPart.Name;
                }
            }
        }