public void UninitializeTransCAD()
 {
     tApp      = null;
     tDocs     = null;
     tPartDoc  = null;
     tPart     = null;
     tAssemDoc = null;
     tFeatures = null;
 }
        //// TransCAD 관련 함수
        public bool InitializeTransCAD(int mode)
        {
            try
            {
                tApp = (TransCAD.IApplication)Marshal.GetActiveObject("TransCAD.IApplication");
            }
            catch
            {
                tApp = (TransCAD.IApplication)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.IAssemDocument)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);
        }
Example #3
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);
        }