Exemplo n.º 1
0
        /// <summary>
        /// 执行数据的导出
        /// </summary>
        /// <param name="message"></param>
        /// <param name="assemblies"></param>
        /// <param name="options"></param>
        /// <param name="projectData"></param>
        /// <param name="bExit"></param>
        /// <returns></returns>
        public static CmdResult executePXML(ref string message, IEnumerable <AssemblyInstance> assemblies, ICamExportIntOptions options, CNCProjectData projectData, out bool bExit)
        {
            assemblies = assemblies.ToList <AssemblyInstance>();
            bool      flag = assemblies.none <AssemblyInstance>();
            CmdResult result;

            if (flag)
            {
                bExit  = true;
                result = CmdResult.Failed;
            }
            else
            {
                bExit = false;
                Document document = assemblies.First <AssemblyInstance>().Document;
                ItTransactionManager.Instance.reset(document);
                using (ItTransaction itTransaction = ItTransactionManager.Instance.start(document, "export CNC data", null))
                {
                    try
                    {
                        ItCreatePXML itCreatePXML = new ItCreatePXML(assemblies, options);
                        itCreatePXML.run(projectData);
                        bExit = itCreatePXML.UserCanceled;
                        itTransaction.commit();
                    }
                    catch (Exception ex)
                    {
                        message = ex.Message;
                        ItLogging.print("Exception in ItCmdCreateMaschData");
                        ItLogging.printException(ex);
                        itTransaction.rollback("Exception");
                        return(CmdResult.Failed);
                    }
                }
                result = CmdResult.Succeeded;
            }
            return(result);
        }
Exemplo n.º 2
0
        // Token: 0x06000009 RID: 9 RVA: 0x000025D4 File Offset: 0x000007D4
        public static CmdResult executeUniCAM(ref string message, IEnumerable <AssemblyInstance> assemblies, ICamExportIntOptions options, CNCProjectData projectData, out bool bExit)
        {
            assemblies = assemblies.ToList <AssemblyInstance>();
            bool      flag = assemblies.none <AssemblyInstance>();
            CmdResult result;

            if (flag)
            {
                bExit  = true;
                result = CmdResult.Failed;
            }
            else
            {
                Document document = assemblies.First <AssemblyInstance>().Document;
                bExit = false;
                bool flag2 = projectData == null;
                if (flag2)
                {
                    ItFailures.PostFailure(ItFailures.CAMMissingProjectData, ElementId.InvalidElementId);
                }
                ItTransactionManager.Instance.reset(document);
                using (ItTransaction itTransaction = ItTransactionManager.Instance.start(document, CamExporter._lclExportCNCTransaction, null))
                {
                    try
                    {
                        int val  = 0;
                        int val2 = 0;
                        foreach (AssemblyInstance assemblyInstance in assemblies)
                        {
                            Parameter parameter = assemblyInstance.getParameter(ItGlobals.PRODNUMBERPARAM, true, true);
                            bool      flag3     = parameter.isNull();
                            if (!flag3)
                            {
                                bool hasValue = parameter.HasValue;
                                if (hasValue)
                                {
                                    RevitElement <Part> part = assemblyInstance.getPart(null);
                                    bool flag4 = part == null;
                                    if (!flag4)
                                    {
                                        Element mainElement = part.getMainElement();
                                        int     val3;
                                        int.TryParse(parameter.AsString(), out val3);
                                        bool flag5 = mainElement is Wall;
                                        if (flag5)
                                        {
                                            val = Math.Max(val, val3);
                                        }
                                        else
                                        {
                                            bool flag6 = mainElement is Floor;
                                            if (flag6)
                                            {
                                                val2 = Math.Max(val2, val3);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        options.TargetDirectory.Create();
                        DirectoryInfo targetDirectory = options.TargetDirectory;
                        foreach (AssemblyInstance assemblyInstance2 in assemblies)
                        {
                            try
                            {
                                Parameter parameter2 = assemblyInstance2.getParameter(ItGlobals.PRODNUMBERPARAM, true, true);
                                bool      flag7      = parameter2 == null;
                                if (!flag7)
                                {
                                    RevitElement <Part> part2 = assemblyInstance2.getPart(null);
                                    bool flag8 = part2 == null;
                                    if (!flag8)
                                    {
                                        Element     mainElement2 = part2.getMainElement();
                                        ProductType product      = part2.productType();
                                        bool        subdirectoryPerProductType = options.SubdirectoryPerProductType;
                                        if (subdirectoryPerProductType)
                                        {
                                            options.TargetDirectory = targetDirectory.CreateSubdirectory(product.ToString());
                                        }
                                        ItMachineDataBase cncdocCreator = ItCNCDataFactory.getCNCDocCreator(assemblyInstance2, options);
                                        bool flag9 = cncdocCreator.isNull();
                                        if (!flag9)
                                        {
                                            bool flag10 = mainElement2 is Wall;
                                            if (flag10)
                                            {
                                                CamExporter.FixProdNumber(parameter2, ref val);
                                            }
                                            else
                                            {
                                                bool flag11 = mainElement2 is Floor;
                                                if (flag11)
                                                {
                                                    CamExporter.FixProdNumber(parameter2, ref val2);
                                                }
                                            }
                                            int    iProdNo            = Convert.ToInt32(parameter2.AsString());
                                            string unitechnikFilename = ItMachineDataBase.GetUnitechnikFilename(assemblyInstance2, options, projectData);
                                            bool   flag12;
                                            CamIntEvents.OnExportingAssembly(document, assemblyInstance2.Id, options, product, unitechnikFilename, out flag12);
                                            bool flag13 = flag12;
                                            if (!flag13)
                                            {
                                                bool flag14  = CamExporter.CheckUnitechnikFilename(options, unitechnikFilename, out bExit);
                                                bool success = false;
                                                bool flag15  = flag14 && !bExit;
                                                if (flag15)
                                                {
                                                    success = cncdocCreator.createMachineDataUnitechnik(assemblyInstance2, iProdNo, projectData, unitechnikFilename);
                                                }
                                                CamIntExportStatus status = CamExporter.DetermineStatus(success, bExit, flag14);
                                                CamIntEvents.OnExportedAssembly(document, assemblyInstance2.Id, options, product, unitechnikFilename, status);
                                                bool flag16 = bExit;
                                                if (flag16)
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (SplitByOpeningNotSupportedException ex)
                            {
                                ItFailures.PostFailure(ItFailures.SplitByOpeningNotSupported, ex.ElementId);
                            }
                        }
                        itTransaction.commit();
                    }
                    catch (Exception ex2)
                    {
                        message = ex2.Message;
                        ItLogging.print("Exception in ItCmdCreateMaschData");
                        ItLogging.printException(ex2);
                        itTransaction.rollback("Exception");
                        return(CmdResult.Failed);
                    }
                }
                result = (bExit ? CmdResult.Cancelled : CmdResult.Succeeded);
            }
            return(result);
        }