private void SavePartFile(ref Inventor.PartDocument PartDocument) { InvApp.SilentOperation = true; if (System.IO.File.Exists(szPartFileNameSavePath)) { System.IO.File.Delete(szPartFileNameSavePath); } PartDocument.SaveAs(szPartFileNameSavePath, false); PartDocument.Close(true); InvApp.SilentOperation = false; }
private void ProcessFileRefs(Inventor.File File) { foreach (Inventor.FileDescriptor DescriptedFile in File.ReferencedFileDescriptors) { if (!DescriptedFile.ReferenceMissing) { if (DescriptedFile.ReferencedFileType != Inventor.FileTypeEnum.kForeignFileType) { if (DescriptedFile.ReferencedFileType == Inventor.FileTypeEnum.kPartFileType) //part or sub; { string TartgetPartNumber = ""; Inventor.PartDocument PartDocument = (Inventor.PartDocument)mInvApplication.Documents.Open(DescriptedFile.FullFileName, false); TartgetPartNumber = PartDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value; if (TartgetPartNumber.StartsWith(txtPartID)) { string TypeOfPart = ""; Inventor._Document Document = (Inventor._Document)PartDocument; // normal part if (PartDocument.SubType != "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { TypeOfPart = "Plate"; DrawDocument(Document, TypeOfPart); } else // if sheet metal { TypeOfPart = "SheetMetal"; DrawDocument(Document, TypeOfPart); } // Document.Close(false); } PartDocument.Close(false); } } } } }
private void GetAllPartsInBom(ref Inventor.AssemblyDocument AssemblyDocument) { Inventor.BOM bOM = AssemblyDocument.ComponentDefinition.BOM; bOM.PartsOnlyViewEnabled = true; bOM.StructuredViewEnabled = true; Inventor.BOMView bOMViews = AssemblyDocument.ComponentDefinition.BOM.BOMViews[3]; Inventor.BOMRowsEnumerator bOMRows = bOMViews.BOMRows; int length = bOMRows.Count; for (int i = 1; i <= length; i++) { Inventor.BOMRow bOMRow = bOMViews.BOMRows[i]; if (true) { Inventor.Document Document = bOMRow.ComponentDefinitions[1].Document; if (Document.DocumentType == Inventor.DocumentTypeEnum.kPartDocumentObject) { string PartNumber = ""; PartNumber = Document.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value; if (CFileNames.IsPartNumberPreFixsMatch(PartNumber, PartNumberID)) { //Inventor.PartDocument PartDocument = (Inventor.PartDocument)Document; Inventor.PartDocument PartDocument = (Inventor.PartDocument)mInvApplication.Documents.Open(Document.FullFileName, true); if (PartDocument.Open) { FileSaveUrl = PartDocument.FullFileName.Substring(0, PartDocument.FullFileName.LastIndexOf(".")); if ((!PartDocument.ComponentDefinition.IsContentMember) || !PartDocument.ComponentDefinition.IsiPartFactory || !PartDocument.ComponentDefinition.IsiPartMember) { //check for Flat Pattern if (PartDocument.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { DXFExport(FileSaveUrl, PartDocument); ListComponents.Items.Add("SM Qty " + bOMRow.ItemQuantity.ToString() + " Part * " + PartDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value + " * "); } else { //if (true) //{ // logWriter.WriteAsync(PartNumber); //} DoCommandExportDXF(PartDocument); ListComponents.Items.Add("Cmmd Qty " + bOMRow.ItemQuantity.ToString() + " Part * " + PartDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value + " * "); } } // ListComponents.Items.Add("Qty " + bOMRow.ItemQuantity.ToString() + " Part * " + PartDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value + " * "); } else { } PartDocument.Close(false); PartDocument = null; } } else if (Document.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject) { Inventor.AssemblyDocument AssemDocument = (Inventor.AssemblyDocument)Document; //ListComponents.Items.Add("Qty " + bOMRow.ItemQuantity.ToString() + " Part * " + AssemDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value + " * "); ListComponents.Items.Add("Qty " + bOMRow.ItemQuantity.ToString() + " Part * " + AssemDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value + " * "); } Document = null; } } }
private void ProcessFileRefs(Inventor.File PartFile) { FileSaveUrl = ""; foreach (Inventor.FileDescriptor FileDescriptor in PartFile.ReferencedFileDescriptors) { if (!FileDescriptor.ReferenceMissing) { if (FileDescriptor.ReferencedFileType != Inventor.FileTypeEnum.kUnknownFileType || FileDescriptor.ReferencedFileType != Inventor.FileTypeEnum.kForeignFileType) { Inventor.File File = FileDescriptor.ReferencedFile; if (File.Type != Inventor.ObjectTypeEnum.kContentCenterObject) { if (FileDescriptor.ReferencedFileType == Inventor.FileTypeEnum.kPartFileType) { string PartNumber = ""; string PartQty = "-Qty"; // FileDescriptor. Inventor.PartDocument mPartDocument = (Inventor.PartDocument)mInvApplication.Documents.Open(FileDescriptor.FullFileName, true); PartNumber = mPartDocument.PropertySets["{32853F0F-3444-11d1-9E93-0060B03C1CA6}"].get_ItemByPropId((int)Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties).Value; PartQty += mPartDocument.PropertySets["{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"].get_ItemByPropId((int)Inventor.PropertiesForSummaryInformationEnum.kKeywordsSummaryInformation).Value; if (CFileNames.IsPartNumberPreFixsMatch(PartNumber, PartNumberID)) { if (FileSaveUrl == "") { if (!IsFileNameQtyAdded) { FileSaveUrl = FileDescriptor.FullFileName.Substring(0, FileDescriptor.FullFileName.LastIndexOf(".")); } else { FileSaveUrl = FileDescriptor.FullFileName.Substring(0, FileDescriptor.FullFileName.LastIndexOf(".")); FileSaveUrl = CFileNames.AppendAffixToFileNameInFullFileName(FileSaveUrl, "-", PartQty); } //check for Flat Pattern if (mPartDocument.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { DXFExport(FileSaveUrl, mPartDocument); } else { //if (true) //{ // logWriter.WriteAsync(PartNumber); //} DoCommandExportDXF(mPartDocument); } } else //with user folder { CFileNames.GetFolderFromFullFileName(FileDescriptor.FullFileName, ref FileSaveUrl, false); FileSaveUrl += PartNumber; //check for Flat Pattern if (mPartDocument.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") { DXFExport(FileSaveUrl, mPartDocument); } else { } } } mPartDocument.Close(false); mPartDocument = null; } } ProcessFileRefs(FileDescriptor.ReferencedFile); } } } }