diff --git a/BIMAPI_HW2/BIMAPI_HW2.csproj b/BIMAPI_HW2/BIMAPI_HW2.csproj index 4ef6cb5..2a0bd41 100644 --- a/BIMAPI_HW2/BIMAPI_HW2.csproj +++ b/BIMAPI_HW2/BIMAPI_HW2.csproj @@ -7,7 +7,7 @@ {1251CFD1-EB24-46F1-9C1A-07773BF85625} Library Properties - BIMAPI_HW2 + BimApiRevitFamilyParametersGenerator BIMAPI_HW2 v4.7.2 512 @@ -17,14 +17,16 @@ true full false - bin\Debug\ - DEBUG;TRACE + bin\Release\ + TRACE prompt 4 + pdbonly true + bin\Release\ TRACE prompt @@ -38,6 +40,12 @@ ..\..\..\..\..\..\Program Files\Autodesk\Revit 2019\RevitAPIUI.dll + + + + + + @@ -49,6 +57,7 @@ + Form @@ -60,6 +69,7 @@ True True Resources.resx + Utils.cs diff --git a/BIMAPI_HW2/Form1.Designer.cs b/BIMAPI_HW2/Form1.Designer.cs index a9b6093..b55de2d 100644 --- a/BIMAPI_HW2/Form1.Designer.cs +++ b/BIMAPI_HW2/Form1.Designer.cs @@ -1,7 +1,7 @@  -namespace BIMAPI_HW2 +namespace BimApiRevitFamilyParametersGenerator { - partial class Form1 + partial partial class FamilyParameterGeneratorForm { /// /// Required designer variable. diff --git a/BIMAPI_HW2/Form1.cs b/BIMAPI_HW2/Form1.cs index 1ba173e..30ef835 100644 --- a/BIMAPI_HW2/Form1.cs +++ b/BIMAPI_HW2/Form1.cs @@ -6,13 +6,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Windows.Forms; +using System.Windows.Forms.IWin32Window; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.DB; -namespace BIMAPI_HW2 +namespace BimApiRevitFamilyParametersGenerator { - public partial class Form1 : System.Windows.Forms.Form + public partial class FamilyParameterGeneratorForm : System.Windows.Forms.Form { public Document doc; public Selection selElement; diff --git a/BIMAPI_HW2/GenerateFamilyParameter.cs b/BIMAPI_HW2/GenerateFamilyParameter.cs index b1cfc40..97c9109 100644 --- a/BIMAPI_HW2/GenerateFamilyParameter.cs +++ b/BIMAPI_HW2/GenerateFamilyParameter.cs @@ -10,15 +10,15 @@ using System.Windows.Forms; using System.Threading.Tasks; using System.Collections.Generic; -using BIMAPI_HW2; +using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB.Structure; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.DB.Events; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace APIFinal +namespace BimApiRevitFamilyParametersGenerator { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] - public class _0104_test : IExternalCommand + public class FamilyParameterGeneratorForm : System.Windows.Forms.Form { - private class ObjectType : EqualityComparer + private class DimensionsComparer : EqualityComparer { int[] _dim = new int[2]; @@ -37,7 +37,7 @@ public string Name get { return H.ToString() + " x " + W.ToString() + "mm"; } } - public ObjectType(int d1, int d2) + public DimensionsComparer(int d1, int d2) { if (d1 > d2) { @@ -63,7 +63,7 @@ public override int GetHashCode(ObjectType obj) public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { - void get_number_of_Object(string path, ref int num) + void GetNumberOfObjects(string path, ref int num) { StreamReader reader = new StreamReader(path); while (reader.Peek() >= 0) @@ -76,7 +76,7 @@ void get_number_of_Object(string path, ref int num) } - void get_ObjectType(string path, ref int[] L1, ref int[] L2) + void GetObjectTypes(string path, ref int[] L1, ref int[] L2) { StreamReader reader = new StreamReader(path); int count = 0; @@ -93,7 +93,8 @@ void get_ObjectType(string path, ref int[] L1, ref int[] L2) } //for loading the BIM model - void load_rfa_element(ref Document document, string path, string name) + void LoadRfaElement(ref Document document, string path, string name) + { Family family = null; using (Transaction tx = new Transaction(document)) @@ -153,7 +154,7 @@ void load_rfa_element(ref Document document, string path, string name) int[] length2 = new int[col_num]; get_ObjectType(Object_type_path, ref length1, ref length2); - List all = new List(); + List allDimensions = new List(); for (int i = 0; i < col_num; ++i) all.Add(new ObjectType(length1[i], length2[i])); all = all.Distinct(new ObjectType(0, 0)).ToList(); @@ -183,8 +184,8 @@ IEnumerable existing return Result.Cancelled; } - List AlreadyExists = new List(); - List ToBeMade = new List(); + List AlreadyExists = new List(); + List ToBeGenerated = new List(); for (int i = 0; i < all.Count; ++i) { @@ -207,7 +208,7 @@ IEnumerable existing //MessageBox.Show("count= " + ToBeMade.Count); using (Transaction tx = new Transaction(doc)) { - if (tx.Start("Make types") == TransactionStatus.Started) + if (tx.Start("Create Types") == TransactionStatus.Started) { FamilySymbol first = existing.First(); foreach (ObjectType ct in ToBeMade) @@ -249,10 +250,10 @@ IEnumerable existing } tx.Commit(); } - string ObjectMessageBox = ""; + string _objectTypeMessageBox = ""; for (int i = 0; i < col_num; i++) { - ObjectMessageBox += "Create " + Object + " " + length1[i] + " X " + length2[i] + " mm\n"; + _objectTypeMessageBox += "Create " + _objectType + " " + length1[i] + " X " + length2[i] + " mm\n"; } MessageBox.Show(ObjectMessageBox); } @@ -271,8 +272,8 @@ IEnumerable existing /* -string Object = "Beam";//結構樑or結構柱 -string rfa_name = "混凝土-矩形樑"; -string rfa_path = "C:/ProgramData/Autodesk/RVT 2019/Libraries/China_Trad/結構構架/混凝土/混凝土-矩形樑.rfa"; -string Object_type_path = "C:/Users/jim/Desktop/test.txt"; +string _objectType = "Beam";//結構樑or結構柱 +string rfaName = "混凝土-矩形樑"; +string rfaPath = "C:/ProgramData/Autodesk/RVT 2019/Libraries/China_Trad/結構構架/混凝土/混凝土-矩形樑.rfa"; +string objectTypePath = "C:/Users/jim/Desktop/test.txt"; */ diff --git a/BIMAPI_HW2/Properties/AssemblyInfo.cs b/BIMAPI_HW2/Properties/AssemblyInfo.cs index f1f5de9..b722582 100644 --- a/BIMAPI_HW2/Properties/AssemblyInfo.cs +++ b/BIMAPI_HW2/Properties/AssemblyInfo.cs @@ -5,7 +5,8 @@ // 組件的一般資訊是由下列的屬性集控制。 // 變更這些屬性的值即可修改組件的相關 // 資訊。 -[assembly: AssemblyTitle("BIMAPI_HW2")] +[assembly: AssemblyTitle("BimApiRevitFamilyParametersGenerator")] +[assembly: AssemblyProduct("BimApiRevitFamilyParametersGenerator")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] diff --git a/BIMAPI_HW2/ShareParameter.txt b/BIMAPI_HW2/ShareParameter.txt index ce4a12a..29aac1d 100644 Binary files a/BIMAPI_HW2/ShareParameter.txt and b/BIMAPI_HW2/ShareParameter.txt differ diff --git a/BIMAPI_HW2/Utils.cs b/BIMAPI_HW2/Utils.cs new file mode 100644 index 0000000..ed1f6a1 --- /dev/null +++ b/BIMAPI_HW2/Utils.cs @@ -0,0 +1,25 @@ +// Utils.cs + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BimApiRevitFamilyParametersGenerator +{ + public static class Utils + { + // Utility functions and helper methods + // ... + + // Moved utility functions from Form1.Designer.cs + // ... + + // Moved utility functions from Form1.cs + // ... + + // Moved utility functions from GenerateFamilyParameter.cs + // ... + } +}