Esempio n. 1
0
        /// <summary>
        /// 获取当前的文档对象
        /// </summary>
        /// <param name="projectData"></param>
        /// <param name="instance"></param>
        /// <param name="options"></param>
        /// <param name="fullFilePath"></param>
        /// <param name="cancel"></param>
        /// <returns></returns>
        private static ItDocument GetDocument(CNCProjectData projectData, AssemblyInstance instance, ICamExportIntOptions options, string fullFilePath, out bool cancel)
        {
            cancel = false;
            bool       flag = instance == null;
            ItDocument result;

            if (flag)
            {
                result = null;
            }
            else
            {
                bool flag2 = ItCNCFileWriter.dontOverwriteExistingFile(fullFilePath, options.OverwriteMode, out cancel);
                bool flag3 = flag2 | cancel;
                if (flag3)
                {
                    result = null;
                }
                else
                {
                    string     fileName      = Path.GetFileName(fullFilePath);
                    string     directoryName = Path.GetDirectoryName(fullFilePath);
                    ItDocument itDocument    = new ItDocument
                    {
                        productType = instance.productType(),
                        FilePath    = directoryName,
                        FileName    = fileName
                    };
                    itDocument.prepare(projectData);
                    result = itDocument;
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 写入文件之中
        /// </summary>
        /// <param name="cncDoc"></param>
        /// <param name="serializer"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private bool WriteFile(ItDocument cncDoc, XmlSerializer serializer, out string fileName)
        {
            cncDoc.convertUnits();
            fileName = Path.Combine(cncDoc.FilePath, cncDoc.FileName);
            bool flag = !cncDoc.IsValid;
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                try
                {
                    using (TextWriter textWriter = new StreamWriter(fileName))
                    {
                        serializer.Serialize(textWriter, cncDoc, cncDoc.Namespaces);
                        return(true);
                    }
                }
                catch (Exception o)
                {
                    o.unused();
                }
                result = false;
            }
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加一个产品
        /// </summary>
        /// <param name="cncDoc"></param>
        private void AddProduct(ItDocument cncDoc)
        {
            bool flag = cncDoc.isNull();

            if (!flag)
            {
                ItOrder itOrder = cncDoc.Orders.LastOrDefault <ItOrder>();
                bool    flag2   = itOrder.isNull();
                if (!flag2)
                {
                    List <ItProduct> productList = itOrder.productList;
                    if (productList != null)
                    {
                        productList.Add(new ItProduct());
                    }
                }
            }
        }
Esempio n. 4
0
        // Token: 0x06000072 RID: 114 RVA: 0x0000543C File Offset: 0x0000363C
        private bool ExportShellToPxml(ItDocument cncDoc, AssemblyInstance assemblyInstance, CNCProjectData projectData, ItMachineDataWallDB.DbwElementData.Shell shell, int doubleWallGapInMM)
        {
            ItGeMatrix3d matWcsToPalette = base.MatWcsToPalette;

            base.MatWcsToPalette = shell.Transformation;
            this.Mode            = shell.Mode;
            bool flag = base.ExportPxml(assemblyInstance, new RevitElement <Part>[]
            {
                shell.Part
            }, cncDoc, projectData);
            bool flag2 = !flag;
            bool result;

            if (flag2)
            {
                result = flag;
            }
            else
            {
                base.MatWcsToPalette = matWcsToPalette;
                result = true;
            }
            return(result);
        }
Esempio n. 5
0
        // Token: 0x06000061 RID: 97 RVA: 0x00004C64 File Offset: 0x00002E64
        public static string GetFileName(AssemblyInstance instance, CNCProjectData projectData, ICamExportIntOptions options, ItDocument cncDoc)
        {
            bool   flag = cncDoc != null && options.MultipleElementsInOneFile;
            string result;

            if (flag)
            {
                result = Path.Combine(cncDoc.FilePath, cncDoc.FileName);
            }
            else
            {
                ItCfgNode itCfgNode;
                if (instance == null)
                {
                    itCfgNode = null;
                }
                else
                {
                    Document document = instance.Document;
                    if (document == null)
                    {
                        itCfgNode = null;
                    }
                    else
                    {
                        ItXmlConfig config = document.getConfig();
                        itCfgNode = ((config != null) ? config.CamRootNode : null);
                    }
                }
                ItCfgNode itCfgNode2 = itCfgNode;
                string    text;
                if (itCfgNode2 == null)
                {
                    text = null;
                }
                else
                {
                    ItCfgNode itCfgNode3 = itCfgNode2["PXML"];
                    text = ((itCfgNode3 != null) ? itCfgNode3["FileNameRules"].value : null);
                }
                string text2 = text;
                bool   flag2 = string.IsNullOrWhiteSpace(text2);
                if (flag2)
                {
                    text2 = "Element_\"ProdNo\".pxml";
                }
                bool flag3 = projectData.isNull();
                if (flag3)
                {
                    result = text2;
                }
                else
                {
                    ProductType   productType   = (instance != null) ? instance.productType() : ProductType.None;
                    DirectoryInfo directoryInfo = options.TargetDirectory;
                    bool          subdirectoryPerProductType = options.SubdirectoryPerProductType;
                    if (subdirectoryPerProductType)
                    {
                        directoryInfo = directoryInfo.CreateSubdirectory(productType.ToString());
                    }
                    string path  = CNCFileNameParser.Parse(text2, instance, projectData, true);
                    string text3 = Path.Combine(directoryInfo.FullName, path);
                    result = text3;
                }
            }
            return(result);
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        // Token: 0x0600006E RID: 110 RVA: 0x0000522C File Offset: 0x0000342C
        protected override bool ExportPxml(AssemblyInstance assemblyInstance, IEnumerable <RevitElement <Part> > part, ItDocument cncDoc, CNCProjectData projectData)
        {
            RevitElement <Part> firstShell;
            RevitElement <Part> secondShell;

            ItMachineDataWallML.GetShells(assemblyInstance, out firstShell, out secondShell);
            ItMachineDataWallDB.DbwElementData dbwElementData = new ItMachineDataWallDB.DbwElementData(base.MatWcsToPalette, firstShell, secondShell);
            ItMachineDataWallDB.DetermineCombinedBoundingBox(dbwElementData);
            ItMachineDataWallDB.DetermineDoubleWallGap(dbwElementData);
            int doubleWallGapInMM = (int)Math.Round(dbwElementData.Gap.FeetToMeter() * 1000.0);

            ItMachineDataWallDB.DetermineShellTransformations(dbwElementData);
            bool flag  = this.ExportShellToPxml(cncDoc, assemblyInstance, projectData, dbwElementData.FirstShell, doubleWallGapInMM);
            bool flag2 = !flag;
            bool result;

            if (flag2)
            {
                result = false;
            }
            else
            {
                flag   = this.ExportShellToPxml(cncDoc, assemblyInstance, projectData, dbwElementData.SecondShell, doubleWallGapInMM);
                result = flag;
            }
            return(result);
        }