public void FileObj(List <BomShell> boomShellList, string pathpdf) { try { foreach (var item in boomShellList) { if (item.FileName != "" && item.PartNumber != "") { IEdmFolder5 folder; string pathfile = item.FolderPath + @"\" + item.FileName; IEdmFile5 file = Vault.GetFileFromPath(pathfile, out folder); file.GetFileCopy(0, 0, 0, (int)EdmGetFlag.EdmGet_Simple); string filepath = file.GetLocalPath(folder.ID); string pathdrw = item.FolderPath + @"\" + item.PartNumber + ".SLDDRW"; IEdmFile5 filedrw = Vault.GetFileFromPath(pathdrw, out folder); if (filedrw != null) { filedrw.GetFileCopy(0, 0, 0, (int)EdmGetFlag.EdmGet_Simple); var filepathdrw = filedrw.GetLocalPath(folder.ID); int filedrwId = filedrw.ID; if (CheckPdf(filedrwId, filedrw, pathpdf) != 0) { CheckPdf(filedrwId, filedrw, pathpdf); } else { LoadPdf lp = new LoadPdf(); string newpath = lp.PdfLoad(filepathdrw, true, pathpdf); byte[] bytes = BinaryPdf(newpath); ProcCheck(file, filedrw, filedrw.CurrentVersion, bytes); } } } } SolidWorksAdapter.KillProcsses("SLDWORKS"); SolidWorksAdapter.DisposeSOLID(); MessageBox.Show("PDF файлы успешно сохранены"); this.Hide(); } catch (Exception e) { MessageBox.Show(e.Message); throw; } }
/// <summary> /// Traverses an argument vault folder object recursively and returns a <see cref="Folder"/> instance /// representing the complete hierarchical tree structure of the vault folder in question. /// This method could be VERY SLOW depending on the size and depth of the folder structure being traversed. /// </summary> /// <param name="folder"></param> /// <returns></returns> public static Folder GetFolderTree(IEdmFolder5 folder) { Folder folderOut = new Folder() { Id = folder.ID, ParentFolderId = folder.ParentFolder == null ? null : new int?(folder.ParentFolder.ID), // This guards against a potential NullReferenceException only for the vault root folder because it will have a null ParentFolder value. Name = folder.Name, Path = folder.LocalPath, }; IEdmPos5 pos = folder.GetFirstFilePosition(); while (!pos.IsNull) { IEdmFile5 edmFile = folder.GetNextFile(pos); var file = new File() { Id = edmFile.ID, Name = edmFile.Name, Path = edmFile.GetLocalPath(folder.ID) // TODO: AcmePartNo = .... }; folderOut.Files.Add(file); } pos = folder.GetFirstSubFolderPosition(); while (!pos.IsNull) { IEdmFolder5 subFolder = folder.GetNextSubFolder(pos); folderOut.Subfolders.Add( GetFolderTree(subFolder)); } return(folderOut); }
public void OnCmd(ref EdmCmd poCmd, ref Array ppoData) { try { //// TODO: This is useful for showing child windows properly //poCmd.mlParentWnd; switch (poCmd.meCmdType) { case EdmCmdType.EdmCmd_Menu: if (poCmd.mlCmdID == 1) { //// TODO: Only supporting single selection for now. //foreach(EdmCmdData d in ppoData) //{ // d.mbsStrData1 = //} var fileData = (EdmCmdData)ppoData.GetValue(0); string fileName = fileData.mbsStrData1; int fileId = fileData.mlObjectID1; int folderId = fileData.mlObjectID3; IEdmVault16 vault = (IEdmVault16)poCmd.mpoVault; IEdmFile5 file = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, fileId); IEdmFolder5 parentFolder = (IEdmFolder5)vault.GetObject(EdmObjectType.EdmObject_Folder, folderId); string parentFilePath = file.GetLocalPath(parentFolder.ID); var fileVars = (IEdmEnumeratorVariable10)file.GetEnumeratorVariable(); // get the variable object oVal; bool success = fileVars.GetVar2(VARIABLE_NAME, "@", parentFolder.ID, out oVal); if (file.IsLocked) { MessageBox.Show("The file must be checked in."); } else if (oVal == null) { MessageBox.Show($"The variable '{VARIABLE_NAME}' has no value."); } else { var window = new AAFileRefsWindow(); // do search and gret results... var search = new VaultSearch(vault); AAFileRef[] results = search.SearchForFileRefs(oVal.ToString()); var vm = new AAFileRefsViewModel(parentFilePath, results, () => window.Close()); window.DataContext = vm; window.ShowDialog(); if (vm.OkWasClicked) { var fileRefsSvc = new CustomRefsService(vault); string[] chilPaths = vm.Results .Where(x => x.IsIncluded) .Select(x => x.Path).ToArray(); fileRefsSvc.AddCustomReferences(file.ID, chilPaths); } } } break; case EdmCmdType.EdmCmd_PostAdd: break; default: break; } } catch (Exception ex) { #if Debug MessageBox.Show(ex.ToString()); #else MessageBox.Show(ex.Message); #endif } }
public bool HaveUpToDateItemRef(IEdmFile5 Part, IEdmVault7 vault) { bool retval = false; long Local = Part.GetLocalVersionNo(Part.GetLocalPath(0)); int Server = Part.CurrentVersion; if (Local == Server) retval = true; return retval; }