/// <summary> /// 创建一个订单 /// </summary> /// <param name="doc"></param> /// <param name="projectData"></param> /// <returns></returns> private static ItOrder CreateOrderInstance(Document doc, CNCProjectData projectData) { bool flag = doc.isNull(); ItOrder result; if (flag) { result = null; } else { ProjectInfo projectInformation = doc.ProjectInformation; ItOrder itOrder = new ItOrder { OrderNo = projectData.General.OrderNumber, Component = projectData.General.Component, Storey = projectData.General.Storey, DrawingNo = projectData.General.DrawingNumber, DrawingDate = projectData.DrawingData.Date, DrawingRevision = projectData.DrawingData.Revision, DrawingAuthor = projectData.DrawingData.Author, Comment = projectData.CommentPXML }; ItCreatePXML.FillProjectDescription(itOrder, projectData); ItCreatePXML.FillBuildingSite(itOrder, projectData); ItCreatePXML.FillBuildingOwner(itOrder, projectData); ItCreatePXML.FillGenericOrderInfo(itOrder, projectData); ItCreatePXML.FillApplicationData(itOrder, doc); result = itOrder; } return(result); }
/// <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); }
/// <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); } }