| | |
| | | using Autodesk.Revit.DB; |
| | | using Autodesk.Revit.DB.Plumbing; |
| | | using Autodesk.Revit.UI; |
| | | using HStation.RevitDev.Model.Enum; |
| | | using HStation.RevitDev.RevitDataExport.Common; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | |
| | | namespace HStation.RevitDev.RevitDataExport.Utility |
| | | { |
| | | public class RevitUtil |
| | | { |
| | | public static List<PipeType> FindPipeTypes(Document doc) |
| | | { |
| | | FilteredElementCollector collector = new FilteredElementCollector(doc); |
| | | var pipeTypes = collector.OfClass(typeof(PipeType)).ToElements().Cast<PipeType>().ToList(); |
| | | return pipeTypes; |
| | | } |
| | | |
| | | public static void CleanPipeThumbnails() |
| | | { |
| | | try |
| | | { |
| | | var pipeDir = Path.Combine(GlobalResource.FamilysDirectory, RevitFamilyType.RFT_Pipe.GetDescription()); |
| | | if (!Directory.Exists(pipeDir)) { return; } |
| | | var pngFiles = Directory.GetFiles(pipeDir, "*.png", SearchOption.TopDirectoryOnly); |
| | | foreach (var pngFile in pngFiles) |
| | | { |
| | | File.Delete(pngFile); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | TaskDialog.Show("警告", $"管道缓存清理失败:{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | public static void SavePipeThumbnails(List<PipeType> pipeTypes) |
| | | { |
| | | var pipeDir = Path.Combine(GlobalResource.FamilysDirectory, RevitFamilyType.RFT_Pipe.GetDescription()); |
| | | for (int i = 0; i < pipeTypes.Count; i++) |
| | | { |
| | | var pipeType = pipeTypes[i]; |
| | | var pipeImg = pipeType.GetPreviewImage(new System.Drawing.Size(GlobalResource.ThumbnailSize, GlobalResource.ThumbnailSize)); |
| | | pipeImg.Save(Path.Combine(pipeDir, $"{pipeType.Name}.png")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | using Autodesk.Revit.DB;
|
| | | using Autodesk.Revit.DB.Plumbing;
|
| | | using Autodesk.Revit.UI;
|
| | | using HStation.RevitDev.Model.ModelEnum;
|
| | | using HStation.RevitDev.RevitDataExport.Common;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Linq;
|
| | | using System.Text.RegularExpressions;
|
| | |
|
| | | namespace HStation.RevitDev.RevitDataExport.Utility
|
| | | {
|
| | | public class RevitUtil
|
| | | {
|
| | | public static List<PipeType> FindPipeTypes(Document doc)
|
| | | {
|
| | | FilteredElementCollector collector = new FilteredElementCollector(doc);
|
| | | var pipeTypes = collector.OfClass(typeof(PipeType)).ToElements().Cast<PipeType>().ToList();
|
| | | return pipeTypes;
|
| | | }
|
| | |
|
| | | public static void CleanPipeThumbnails()
|
| | | {
|
| | | try
|
| | | {
|
| | | var pipeDir = Path.Combine(GlobalResource.FamilysDirectory, RevitType.RFT_Pipe.GetDescription());
|
| | | if (!Directory.Exists(pipeDir)) { return; }
|
| | | var pngFiles = Directory.GetFiles(pipeDir, "*.png", SearchOption.TopDirectoryOnly);
|
| | | foreach (var pngFile in pngFiles)
|
| | | {
|
| | | File.Delete(pngFile);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | TaskDialog.Show("警告", $"管道缓存清理失败:{ex.Message}");
|
| | | }
|
| | | }
|
| | |
|
| | | public static void SavePipeThumbnails(List<PipeType> pipeTypes)
|
| | | {
|
| | | var pipeDir = Path.Combine(GlobalResource.FamilysDirectory, RevitType.RFT_Pipe.GetDescription());
|
| | | for (int i = 0; i < pipeTypes.Count; i++)
|
| | | {
|
| | | var pipeType = pipeTypes[i];
|
| | | var pipeImg = pipeType.GetPreviewImage(new System.Drawing.Size(GlobalResource.ThumbnailSize, GlobalResource.ThumbnailSize));
|
| | | pipeImg.Save(Path.Combine(pipeDir, $"{pipeType.Name}.png"));
|
| | | }
|
| | | }
|
| | |
|
| | | public static IEnumerable<string> ValidateFileVersion(string[] selectPaths)
|
| | | {
|
| | | var result = new List<string>();
|
| | | foreach (var selectPath in selectPaths)
|
| | | {
|
| | | var fileVersion = VersionUtil.GetVersion(selectPath);
|
| | | if (fileVersion == null)
|
| | | {
|
| | | TaskDialog.Show("警告", "无法检测文件版本,载入族文件失败!");
|
| | | }
|
| | | if (fileVersion.CompareTo(GlobalResource.CurrentRevitVersion) > 0)
|
| | | {
|
| | | TaskDialog.Show("警告", "文件版本高于当前Revit版本,无法载入族文件!");
|
| | | }
|
| | | else
|
| | | {
|
| | | result.Add(selectPath);
|
| | | }
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | public static bool IsBackUpFile(string path)
|
| | | {
|
| | | if (!File.Exists(path))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var fileName = Path.GetFileName(path);
|
| | | var pattern = @"\.[\d]{4}\.rfa";
|
| | | bool match = Regex.IsMatch(fileName, pattern);
|
| | | if (match) |
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
| | | }
|