添加项目文件。
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IFC_Revit_Interop.TestTools
|
||||
{
|
||||
// Token: 0x0200001F RID: 31
|
||||
public class ClassificationInfo
|
||||
{
|
||||
// Token: 0x04000091 RID: 145
|
||||
public HashSet<string> FamilyNames = new HashSet<string>();
|
||||
|
||||
// Token: 0x04000092 RID: 146
|
||||
public HashSet<string> CategoryNames = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace IFC_Revit_Interop.TestTools
|
||||
{
|
||||
// Token: 0x02000021 RID: 33
|
||||
[Transaction( TransactionMode.Manual)]
|
||||
[Regeneration(0)]
|
||||
internal class Command_ClassificationExportMulti : IExternalCommand
|
||||
{
|
||||
// Token: 0x06000090 RID: 144 RVA: 0x00007B38 File Offset: 0x00005D38
|
||||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
||||
{
|
||||
string text = "E:/_BIM/宜宾WDGC";
|
||||
List<string> list = new List<string>();
|
||||
Command_ClassificationExportMulti.FindFile(new DirectoryInfo(text), list);
|
||||
Document document = null;
|
||||
foreach (string text2 in list)
|
||||
{
|
||||
if (File.Exists(text2))
|
||||
{
|
||||
UIDocument uidocument = commandData.Application.OpenAndActivateDocument(text2);
|
||||
if (document != null)
|
||||
{
|
||||
document.Close(false);
|
||||
}
|
||||
new Command_Test_ClassificationExport().Execute(commandData, ref message, elements);
|
||||
document = uidocument.Document;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Token: 0x06000091 RID: 145 RVA: 0x00007BCC File Offset: 0x00005DCC
|
||||
private static void FindFile(DirectoryInfo di, List<string> record)
|
||||
{
|
||||
FileInfo[] files = di.GetFiles();
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
if (Path.GetExtension(files[i].FullName) == ".rvt")
|
||||
{
|
||||
record.Add(files[i].FullName);
|
||||
}
|
||||
}
|
||||
DirectoryInfo[] directories = di.GetDirectories();
|
||||
for (int j = 0; j < directories.Length; j++)
|
||||
{
|
||||
Command_ClassificationExportMulti.FindFile(directories[j], record);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IFC_Revit_Interop.TestTools
|
||||
{
|
||||
// Token: 0x02000020 RID: 32
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
[Regeneration(0)]
|
||||
internal class Command_Test_ClassificationExport : IExternalCommand
|
||||
{
|
||||
// Token: 0x0600008E RID: 142 RVA: 0x000078DC File Offset: 0x00005ADC
|
||||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
||||
{
|
||||
string text = "d:/record.json";
|
||||
Dictionary<string, ClassificationInfo> dictionary = new Dictionary<string, ClassificationInfo>();
|
||||
if (File.Exists(text))
|
||||
{
|
||||
StreamReader streamReader = new StreamReader(text);
|
||||
string text2 = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
dictionary = JsonConvert.DeserializeObject<Dictionary<string, ClassificationInfo>>(text2);
|
||||
}
|
||||
Document document = commandData.Application.ActiveUIDocument.Document;
|
||||
foreach (Element element in new FilteredElementCollector(document).WhereElementIsNotElementType().WhereElementIsViewIndependent())
|
||||
{
|
||||
string text3 = null;
|
||||
string text4 = null;
|
||||
Element element2 = null;
|
||||
if (element.Category != null)
|
||||
{
|
||||
text3 = element.Category.Name;
|
||||
}
|
||||
FamilyInstance familyInstance = element as FamilyInstance;
|
||||
if (familyInstance != null)
|
||||
{
|
||||
element2 = familyInstance.Symbol;
|
||||
text4 = familyInstance.Symbol.FamilyName;
|
||||
}
|
||||
else if (element.GetTypeId() != ElementId.InvalidElementId)
|
||||
{
|
||||
ElementType elementType = document.GetElement(element.GetTypeId()) as ElementType;
|
||||
if (elementType != null)
|
||||
{
|
||||
element2 = elementType;
|
||||
text4 = "系统族:" + elementType.FamilyName;
|
||||
}
|
||||
}
|
||||
HashSet<string> hashSet = new HashSet<string>();
|
||||
Parameter parameter = element.LookupParameter("构件分类编码");
|
||||
if (parameter != null && parameter.HasValue)
|
||||
{
|
||||
string text5 = parameter.AsString();
|
||||
if (!string.IsNullOrEmpty(text5))
|
||||
{
|
||||
hashSet.Add(text5);
|
||||
}
|
||||
}
|
||||
if (element2 != null)
|
||||
{
|
||||
parameter = element2.LookupParameter("构件分类编码");
|
||||
if (parameter != null && parameter.HasValue)
|
||||
{
|
||||
string text6 = parameter.AsString();
|
||||
if (!string.IsNullOrEmpty(text6))
|
||||
{
|
||||
hashSet.Add(text6);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (string text7 in hashSet)
|
||||
{
|
||||
if (!dictionary.ContainsKey(text7))
|
||||
{
|
||||
dictionary.Add(text7, new ClassificationInfo());
|
||||
}
|
||||
if (text3 != null)
|
||||
{
|
||||
dictionary[text7].CategoryNames.Add(text3);
|
||||
}
|
||||
if (text4 != null)
|
||||
{
|
||||
dictionary[text7].FamilyNames.Add(text4);
|
||||
}
|
||||
}
|
||||
}
|
||||
string text8 = JsonConvert.SerializeObject(dictionary);
|
||||
StreamWriter streamWriter = new StreamWriter(text);
|
||||
streamWriter.Write(text8);
|
||||
streamWriter.Close();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user