From ddc463824b7250de33c3fc97556e8197dc8b1920 Mon Sep 17 00:00:00 2001 From: Zhuangkh Date: Wed, 12 Oct 2022 17:59:18 +0800 Subject: [PATCH] update installer --- uBIMEarthTools/Commands/GeologyCylinder.cs | 6 +-- uBIMEarthTools/Commands/GeologyModel.cs | 46 ++++++++++++++---- .../地质钻孔圆柱.rfa | Bin .../常规模型地质块.rfa | Bin .../{Resources => Family}/钻孔标记.rfa | Bin uBIMEarthTools/uBIMEarthTools.csproj | 24 +++++++-- 6 files changed, 58 insertions(+), 18 deletions(-) rename uBIMEarthTools/{Resources => Family}/地质钻孔圆柱.rfa (100%) rename uBIMEarthTools/{Resources => Family}/常规模型地质块.rfa (100%) rename uBIMEarthTools/{Resources => Family}/钻孔标记.rfa (100%) diff --git a/uBIMEarthTools/Commands/GeologyCylinder.cs b/uBIMEarthTools/Commands/GeologyCylinder.cs index 386ac26..d21a95d 100644 --- a/uBIMEarthTools/Commands/GeologyCylinder.cs +++ b/uBIMEarthTools/Commands/GeologyCylinder.cs @@ -18,6 +18,7 @@ using System.Runtime.InteropServices; using TriangleNet; using uBIMEarthTools.Utils; using uBIMEarthTools.Model; +using System.Reflection; namespace uBIMEarthTools.Commands { @@ -61,11 +62,8 @@ namespace uBIMEarthTools.Commands if (!familys.Any()) { transaction.Start("Load Family"); - byte[] bit = Resource.地质钻孔圆柱 as byte[]; - string filepath = AppConfig.APP_TEMP_PATH + "\\地质钻孔圆柱.rfa"; - File.WriteAllBytes(filepath, bit); + string filepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "\\Family\\地质钻孔圆柱.rfa"; doc.LoadFamily(filepath); - File.Delete(filepath); transaction.Commit(); } diff --git a/uBIMEarthTools/Commands/GeologyModel.cs b/uBIMEarthTools/Commands/GeologyModel.cs index 9bd2fcb..2fb62ce 100644 --- a/uBIMEarthTools/Commands/GeologyModel.cs +++ b/uBIMEarthTools/Commands/GeologyModel.cs @@ -5,7 +5,9 @@ using Autodesk.Revit.UI; using System.Collections.Generic; using System.Data; using System.Diagnostics; +using System.IO; using System.Linq; +using System.Reflection; using System.Windows.Forms; using uBIMEarthTools.Core; using uBIMEarthTools.Model; @@ -123,18 +125,32 @@ namespace uBIMEarthTools.Commands Common.SetTransaction(transaction); #region 创建钻孔标记 - transaction.Start("load the FamilySymbol"); - IEnumerable familysymbols_bj = from elem in new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)) - let fstmp = elem as FamilySymbol - where fstmp.Name.Contains("钻孔标记") - select fstmp; - if (!familysymbols_bj.Any()) + + IEnumerable familys = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).OfClass(typeof(FamilySymbol)).Where(x => x.Name == "钻孔标记"); + if (!familys.Any()) { - MessageBox.Show("请先加载配套的“钻孔标记”族。", "uBIM", MessageBoxButtons.OK); - status = transGroup.Assimilate(); - return Result.Succeeded; + transaction.Start("Load Family"); + string filepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "\\Family\\钻孔标记.rfa"; + doc.LoadFamily(filepath); + transaction.Commit(); } - FamilySymbol fs_bj = doc.GetElement(familysymbols_bj.First().Id) as FamilySymbol; + + transaction.Start("load the FamilySymbol"); + //IEnumerable familysymbols_bj = from elem in new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)) + // let fstmp = elem as FamilySymbol + // where fstmp.Name.Contains("钻孔标记") + // select fstmp; + //if (!familysymbols_bj.Any()) + //{ + // MessageBox.Show("请先加载配套的“钻孔标记”族。", "uBIM", MessageBoxButtons.OK); + // status = transGroup.Assimilate(); + // return Result.Succeeded; + //} + //FamilySymbol fs_bj = doc.GetElement(familysymbols_bj.First().Id) as FamilySymbol; + //fs_bj.Activate(); + var fs_bj = (new FilteredElementCollector(doc) + .OfCategory(BuiltInCategory.OST_GenericModel).OfClass(typeof(FamilySymbol)) + .Where(x => x.Name == "钻孔标记").First() as FamilySymbol); fs_bj.Activate(); transaction.Commit(); @@ -237,8 +253,18 @@ namespace uBIMEarthTools.Commands #region 创建常规模型地质块 using (FilterProgressForm prf1 = new FilterProgressForm("生成地质模型", "{0} of " + geologyBlocks.Count.ToString(), geologyBlocks.Count)) { + familys = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).OfClass(typeof(FamilySymbol)).Where(x => x.Name == "常规模型地质块"); + if (!familys.Any()) + { + transaction.Start("Load Family"); + string filepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + "\\Family\\常规模型地质块.rfa"; + doc.LoadFamily(filepath); + transaction.Commit(); + } + Family family = (new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel) .OfClass(typeof(FamilySymbol)).First(x => x.Name == "常规模型地质块") as FamilySymbol).Family; + Autodesk.Revit.DB.Document fdoc = doc.EditFamily(family); Transaction trans = new Transaction(fdoc); trans.Start("Create FamilySymbol"); diff --git a/uBIMEarthTools/Resources/地质钻孔圆柱.rfa b/uBIMEarthTools/Family/地质钻孔圆柱.rfa similarity index 100% rename from uBIMEarthTools/Resources/地质钻孔圆柱.rfa rename to uBIMEarthTools/Family/地质钻孔圆柱.rfa diff --git a/uBIMEarthTools/Resources/常规模型地质块.rfa b/uBIMEarthTools/Family/常规模型地质块.rfa similarity index 100% rename from uBIMEarthTools/Resources/常规模型地质块.rfa rename to uBIMEarthTools/Family/常规模型地质块.rfa diff --git a/uBIMEarthTools/Resources/钻孔标记.rfa b/uBIMEarthTools/Family/钻孔标记.rfa similarity index 100% rename from uBIMEarthTools/Resources/钻孔标记.rfa rename to uBIMEarthTools/Family/钻孔标记.rfa diff --git a/uBIMEarthTools/uBIMEarthTools.csproj b/uBIMEarthTools/uBIMEarthTools.csproj index 8f62096..1b9b45f 100644 --- a/uBIMEarthTools/uBIMEarthTools.csproj +++ b/uBIMEarthTools/uBIMEarthTools.csproj @@ -4,17 +4,19 @@ true true + + + + + + - Always - - Always - @@ -25,4 +27,18 @@ + + + Always + + + Always + + + Always + + + Always + +