예제 #1
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
        internal static CmdResult Export(Document document, ref string message, IEnumerable <AssemblyInstance> assemblies, ICamExportIntOptions options, bool variedFormats, out bool bCancelCommand)
        {
            bCancelCommand = false;
            assemblies     = ((assemblies != null) ? assemblies.ToList <AssemblyInstance>() : null);
            bool      flag = assemblies == null || assemblies.none <AssemblyInstance>();
            CmdResult result;

            if (flag)
            {
                result = CmdResult.Succeeded;
            }
            else
            {
                IEnumerable <ElementId> assemblyInstanceIds = (from element in assemblies
                                                               select element.Id).ToList <ElementId>();
                bool flag2;
                CamIntEvents.OnExporting(document, assemblyInstanceIds, options, out flag2);
                CmdResult cmdResult = CmdResult.Succeeded;
                bool      flag3     = !flag2;
                if (flag3)
                {
                    CNCProjectData cncprojectData = CamExporter.GetCNCProjectData(document, options.FileFormat);
                    switch (options.FileFormat)
                    {
                    case FileFormat.Unitechnik52:
                    case FileFormat.Unitechnik60:
                        cmdResult = CamExporter.executeUniCAM(ref message, assemblies, options, cncprojectData, out bCancelCommand);
                        break;

                    case FileFormat.PXML13:
                        cmdResult = CamExporter.executePXML(ref message, assemblies, options, cncprojectData, out bCancelCommand);
                        break;

                    default:
                        throw new InvalidOperationException("Unknown file format for CAM export.");
                    }
                    bool flag4 = cmdResult == CmdResult.Failed;
                    if (flag4)
                    {
                        CamExporter.showError(options.FileFormat);
                    }
                }
                CamIntExportStatus status = CamExporter.DetermineStatus(cmdResult, bCancelCommand, flag2);
                CamIntEvents.OnExported(document, assemblyInstanceIds, options, status);
                result = cmdResult;
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 执行导出操作
        /// </summary>
        /// <param name="projectData"></param>
        public void run(CNCProjectData projectData)
        {
            XmlRootAttribute root = new XmlRootAttribute("PXML_Document")
            {
                Namespace = "http://progress-m.com/ProgressXML/Version1"
            };

            XmlSerializer     serializer = new XmlSerializer(typeof(ItDocument), root);
            List <ItDocument> list       = new List <ItDocument>();
            ItDocument        itDocument = null;

            this._options.TargetDirectory.Create();

            //读取所有的部件
            foreach (AssemblyInstance assemblyInstance in this._assemblies)
            {
                ProductType productType = assemblyInstance.productType();


                bool flag = productType == ProductType.None;
                if (flag)
                {
                    ItFailures.PostFailure(ItFailures.CAMManualCreatedAssemblyNotSupported, assemblyInstance.Id);
                }
                else
                {
                    bool flag2 = this.IsAlreadyWritten(assemblyInstance, list);
                    if (!flag2)
                    {
                        string fileName = ItCreatePXML.GetFileName(assemblyInstance, projectData, this._options, itDocument);
                        bool   flag3;
                        CamIntEvents.OnExportingAssembly(this._rvtDoc, assemblyInstance.Id, this._options, productType, fileName, out flag3);
                        bool flag4 = flag3;
                        if (flag4)
                        {
                            CamIntEvents.OnExportedAssembly(this._rvtDoc, assemblyInstance.Id, this._options, productType, fileName, CamIntExportStatus.EventCanceled);
                        }
                        else
                        {
                            bool flag5 = !this._options.MultipleElementsInOneFile || itDocument == null;
                            if (flag5)
                            {
                                bool userCanceled;
                                itDocument        = ItCreatePXML.GetDocument(projectData, assemblyInstance, this._options, fileName, out userCanceled);
                                this.UserCanceled = userCanceled;
                                bool userCanceled2 = this.UserCanceled;
                                if (userCanceled2)
                                {
                                    CamIntEvents.OnExportedAssembly(this._rvtDoc, assemblyInstance.Id, this._options, productType, fileName, CamIntExportStatus.UserCanceled);
                                    return;
                                }
                                bool flag6 = itDocument == null;
                                if (flag6)
                                {
                                    CamIntEvents.OnExportedAssembly(this._rvtDoc, assemblyInstance.Id, this._options, productType, fileName, CamIntExportStatus.Skipped);
                                    bool multipleElementsInOneFile = this._options.MultipleElementsInOneFile;
                                    if (multipleElementsInOneFile)
                                    {
                                        return;
                                    }
                                    continue;
                                }
                                else
                                {
                                    list.Add(itDocument);
                                    ItOrder        item   = ItCreatePXML.CreateOrderInstance(this._rvtDoc, projectData);
                                    List <ItOrder> orders = itDocument.Orders;
                                    if (orders != null)
                                    {
                                        orders.Add(item);
                                    }
                                }
                            }
                            this.AddProduct(itDocument);
                            ItMachineDataBase   cncdocCreator   = ItCNCDataFactory.getCNCDocCreator(assemblyInstance, this._options);
                            RevitElement <Part> partOfShellType = assemblyInstance.getPartOfShellType(ShellType.FirstShell);
                            itDocument.IsValid = cncdocCreator.CreateMachineDataPxml(assemblyInstance, partOfShellType, itDocument, projectData);
                            CamIntExportStatus status = CamIntExportStatus.None;
                            bool flag7 = !this._options.MultipleElementsInOneFile;
                            if (flag7)
                            {
                                string text;
                                bool   flag8 = this.WriteFile(itDocument, serializer, out text);
                                bool   flag9 = flag8;
                                if (flag9)
                                {
                                    int num = this.Successes;
                                    this.Successes = num + 1;
                                    status         = CamIntExportStatus.Success;
                                }
                                else
                                {
                                    int num = this.Failures;
                                    this.Failures = num + 1;
                                    status        = CamIntExportStatus.Failed;
                                }
                            }
                            CamIntEvents.OnExportedAssembly(this._rvtDoc, assemblyInstance.Id, this._options, productType, fileName, status);
                        }
                    }
                }
            }
            bool flag10 = this._options.MultipleElementsInOneFile && itDocument != null;

            if (flag10)
            {
                string             fileName2;
                bool               flag11 = this.WriteFile(itDocument, serializer, out fileName2);
                bool               flag12 = flag11;
                CamIntExportStatus status2;
                if (flag12)
                {
                    int num = this.Successes;
                    this.Successes = num + 1;
                    status2        = CamIntExportStatus.Success;
                }
                else
                {
                    int num = this.Failures;
                    this.Failures = num + 1;
                    status2       = CamIntExportStatus.Failed;
                }
                CamIntEvents.OnExportedAssembly(this._rvtDoc, ElementId.InvalidElementId, this._options, ProductType.None, fileName2, status2);
            }
        }
예제 #3
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);
        }