Exemple #1
0
        /// <summary>
        /// 批量将给定目录drw导出到指定目录pdf文件
        /// </summary>
        /// <param name="args"> arg0: proe app path arg1 :dir of drw files arg2 :dir for output </param>
        private static void Main(string[] args)
        {
            IpfcAsyncConnection asyncConnection = null;
            Istringseq          Files;
            string proeapp, inputdir, outputdir;

            if (args.Length != 3)
            {
                Console.Write("参数数目不正确.");
                System.Environment.Exit(0);
            }
            proeapp   = args[0] + " -g:no_graphics -i:rpc_input";
            inputdir  = args[1] + "\\";
            outputdir = args[2] + "\\";
            if (Directory.Exists(inputdir) == false)//如果不存在就创建file文件夹
            {
                Console.Write("输入文件夹不存在,程序退出.");
                System.Environment.Exit(0);
            }
            if (Directory.Exists(outputdir) == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory(outputdir);
            }
            Console.WriteLine("开始转换...");
            try
            {
                asyncConnection = new CCpfcAsyncConnection().Start(proeapp, "");
            }
            catch
            {
                Console.WriteLine("无法建立与Creo的连接.");
                System.Environment.Exit(0);
            }
            Console.WriteLine("Creo会话创建完毕...");
            try
            {
                Console.WriteLine(inputdir + "读取中...");
                Files = ((IpfcBaseSession)(asyncConnection.Session)).ListFiles("*.drw", (int)EpfcFileListOpt.EpfcFILE_LIST_LATEST, inputdir);
                Console.WriteLine("drw文件列表读取完毕...");
                foreach (string file in Files)
                {
                    ConvertToPdf(asyncConnection, file, outputdir);
                }
            }
            catch
            {
                Console.WriteLine("无法读取" + inputdir + "...");
            }
            finally
            {
                try
                {
                    asyncConnection.End();
                }
                catch
                {
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 批量将给定目录prt的添加指定txt文件下的关系
        /// </summary>
        /// <param name="args"> arg0: proe app path arg1: dir of prt files arg2: txt file contents relations </param>
        private static void Main(string[] args)
        {
            IpfcAsyncConnection asyncConnection = null;
            Istringseq          Files;

            string[] relations;
            string   proeapp, inputdir, relfile;

            if (args.Length != 3)
            {
                Console.Write("参数数目不正确.");
                System.Environment.Exit(0);
            }
            proeapp  = args[0] + " -g:no_graphics -i:rpc_input";
            inputdir = args[1] + "\\";
            relfile  = args[2];
            if (Directory.Exists(inputdir) == false)
            {
                Console.Write("输入文件夹不存在,程序退出.");
                System.Environment.Exit(0);
            }
            if (File.Exists(relfile) == false)
            {
                Console.Write("输入关系文件不存在,程序退出.");
                System.Environment.Exit(0);
            }
            relations = Getrels(relfile);
            Console.WriteLine("开始添加...");
            try
            {
                asyncConnection = new CCpfcAsyncConnection().Start(proeapp, "");
            }
            catch
            {
                Console.WriteLine("无法建立与Creo的连接.");
                System.Environment.Exit(0);
            }
            Console.WriteLine("Creo会话创建完毕...");
            try
            {
                Console.WriteLine(inputdir + "读取中...");
                Files = ((IpfcBaseSession)(asyncConnection.Session)).ListFiles("*.prt", (int)EpfcFileListOpt.EpfcFILE_LIST_LATEST, inputdir);
                Console.WriteLine("prt文件列表读取完毕...");
                foreach (string file in Files)
                {
                    AddRelations(asyncConnection, file, relations);
                }
            }
            catch
            {
                Console.WriteLine("无法读取" + inputdir + "...");
            }
            finally
            {
                try
                {
                    asyncConnection.End();
                }
                catch
                {
                }
            }
        }