263 lines
10 KiB
C#
263 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.UI.Selection;
|
|
using System.Threading.Tasks;
|
|
using KDCS.Utils;
|
|
using System.Collections;
|
|
using System.Windows.Forms;
|
|
using Autodesk.Revit.DB.Plumbing;
|
|
using Autodesk.Revit.DB.Mechanical;
|
|
using System.Xml.Linq;
|
|
using Autodesk.Revit.UI.Events;
|
|
using System.IO;
|
|
using KMBIM.Revit.Tools;
|
|
using KMBIM.Revit.Tools.Cmd.ColorSort;
|
|
using System.Resources;
|
|
using KMBIM.Revit.Tools.Cmd.PipeMatchInterval;
|
|
using KMBIM.Revit.Tools.Cmd.DuctOffsetConnect;
|
|
using Autodesk.Revit.DB.Structure;
|
|
using Autodesk.Revit.DB.Events;
|
|
using Autodesk.Revit.UI;
|
|
using View = Autodesk.Revit.DB.View;
|
|
|
|
namespace KMBIM
|
|
{
|
|
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
|
|
|
public class SheetLink : IExternalCommand
|
|
{
|
|
UIApplication uiapp;
|
|
UIDocument uidoc;
|
|
Autodesk.Revit.DB.Document doc;
|
|
|
|
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
{
|
|
uiapp = commandData.Application;
|
|
uidoc = uiapp.ActiveUIDocument;
|
|
doc = uidoc.Document;
|
|
|
|
|
|
|
|
List<Category> Annocatlst = new List<Category>();
|
|
List<Category> Modelcatlst = new List<Category>();
|
|
//현재 도면에 존재하는 모델,주석 카테고리 리스트 추출하기
|
|
foreach (Category c in doc.Settings.Categories)
|
|
{
|
|
bool foundInstance = false;
|
|
|
|
foreach (Element elm in new FilteredElementCollector(doc)
|
|
.WhereElementIsNotElementType()
|
|
.OfCategoryId(c.Id))
|
|
{
|
|
foundInstance = true;
|
|
break;
|
|
}
|
|
|
|
if (foundInstance)
|
|
{
|
|
if (c.CategoryType == CategoryType.Annotation)
|
|
Annocatlst.Add(c);
|
|
else if (c.CategoryType == CategoryType.Model)
|
|
{
|
|
if (c.AllowsBoundParameters == true)
|
|
{
|
|
if(c.Id.IntegerValue==(int)BuiltInCategory.OST_ProjectInformation
|
|
|| c.Id.IntegerValue == (int)BuiltInCategory.OST_RvtLinks) { }
|
|
else
|
|
Modelcatlst.Add(c);
|
|
}
|
|
|
|
}
|
|
else if (c.CategoryType == CategoryType.Internal)
|
|
if(c.Id.IntegerValue != (int)BuiltInCategory.OST_Schedules)
|
|
Modelcatlst.Add(c);
|
|
}
|
|
}
|
|
//스케쥴 리스트
|
|
List<Element> SchduleLst = new FilteredElementCollector(doc)
|
|
.WhereElementIsNotElementType()
|
|
.OfCategory(BuiltInCategory.OST_Schedules).ToList();
|
|
|
|
//이름순 정렬
|
|
Annocatlst.Sort((a, b) => a.Name.CompareTo(b.Name));
|
|
Modelcatlst.Sort((a, b) => a.Name.CompareTo(b.Name));
|
|
SchduleLst.Sort((a, b) => a.Name.CompareTo(b.Name));
|
|
|
|
|
|
string aa = "", bb = "";
|
|
foreach(var cat in Annocatlst)
|
|
aa += cat.Name + "\n";
|
|
|
|
foreach (var cat in Modelcatlst)
|
|
bb += cat.Name + "\n";
|
|
|
|
//MessageBox.Show(aa,"주석");
|
|
//MessageBox.Show(bb,"모델");
|
|
|
|
|
|
Form_SheetLink dlg = new Form_SheetLink();
|
|
|
|
//dlg.ExtCatElemLst = m_ExtCatElemLst;
|
|
//dlg.chkCatLst = m_chkCatLst;
|
|
dlg.m_doc = doc;
|
|
dlg.m_Modelcatlst = Modelcatlst;
|
|
dlg.m_Annocatlst = Annocatlst;
|
|
dlg.m_SchduleLst = SchduleLst;
|
|
|
|
if (dlg.ShowDialog() == DialogResult.Cancel) return Result.Cancelled;
|
|
|
|
|
|
|
|
|
|
return Result.Succeeded;
|
|
}
|
|
|
|
//배관류 리스트
|
|
public SheetPipeInfo getSheetPipeInfoLst(List<Element> m_ElemLst)
|
|
{
|
|
SheetPipeInfo pInfo = new SheetPipeInfo();
|
|
|
|
foreach (Element elem in m_ElemLst)
|
|
{
|
|
|
|
if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_PipeCurves)
|
|
{
|
|
if (elem as Pipe != null)
|
|
pInfo.m_PipeInfoLst.Add(elem as Pipe);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_FlexPipeCurves)
|
|
{
|
|
if (elem as FlexPipe != null)
|
|
pInfo.m_FlexPipeInfoLst.Add(elem as FlexPipe);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_PipeFitting)
|
|
{
|
|
if(elem as FamilyInstance != null)
|
|
pInfo.m_PipeFittingLst.Add(elem as FamilyInstance);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_PipingSystem)
|
|
{
|
|
if (elem as PipingSystem != null)
|
|
pInfo.m_PipingSysLst.Add(elem as PipingSystem);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Sprinklers)
|
|
{
|
|
if (elem as FamilyInstance != null)
|
|
pInfo.m_SpkrLst.Add(elem as FamilyInstance);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_PlumbingFixtures)
|
|
{
|
|
if (elem as FamilyInstance != null)
|
|
pInfo.m_PlumbingLst.Add(elem as FamilyInstance);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_MechanicalEquipment)
|
|
{
|
|
if (elem as FamilyInstance != null)
|
|
pInfo.m_MachineEquipLst.Add(elem as FamilyInstance);
|
|
}
|
|
}//foreach end
|
|
return pInfo;
|
|
}
|
|
//덕트류 리스트
|
|
public SheetDuctInfo getSheetDuctInfoLst(List<Element> m_ElemLst)
|
|
{
|
|
SheetDuctInfo dInfo = new SheetDuctInfo();
|
|
|
|
foreach (Element elem in m_ElemLst)
|
|
{
|
|
|
|
if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_DuctCurves)
|
|
{
|
|
if (elem as Duct != null)
|
|
dInfo.m_DuctInfoLst.Add(elem as Duct);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_FlexDuctCurves)
|
|
{
|
|
if (elem as FlexDuct != null)
|
|
dInfo.m_FlexDuctInfoLst.Add(elem as FlexDuct);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_DuctFitting)
|
|
{
|
|
if (elem as FamilyInstance != null)
|
|
dInfo.m_DuctFittingLst.Add(elem as FamilyInstance);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_DuctSystem)
|
|
{
|
|
if (elem as MEPSystem != null)
|
|
dInfo.m_DuctSysLst.Add(elem as MEPSystem);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_DuctAccessory)
|
|
{
|
|
if (elem as FamilyInstance != null)
|
|
dInfo.m_DuctAccLst.Add(elem as FamilyInstance);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_DuctTerminal)
|
|
{
|
|
if (elem as FamilyInstance != null)
|
|
dInfo.m_DuctTerminal.Add(elem as FamilyInstance);
|
|
}
|
|
|
|
}//foreach end
|
|
return dInfo;
|
|
}
|
|
//기타 리스트
|
|
public SheetETCInfo GetSheetETCInfoLst(List<Element> m_ElemLst)
|
|
{
|
|
SheetETCInfo eInfo = new SheetETCInfo();
|
|
|
|
foreach(Element elem in m_ElemLst)
|
|
{
|
|
if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_HVAC_Zones)
|
|
{
|
|
if (elem as Zone != null)
|
|
eInfo.m_HVACLst.Add(elem as Zone);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Views)
|
|
{
|
|
if (elem as View != null)
|
|
eInfo.m_ViewLst.Add(elem as View);
|
|
}
|
|
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Materials)
|
|
{
|
|
if (elem as Material != null)
|
|
eInfo.m_MaterialLst.Add(elem as Material);
|
|
}
|
|
}
|
|
|
|
return eInfo;
|
|
}
|
|
|
|
public class SheetPipeInfo
|
|
{
|
|
public List<Pipe> m_PipeInfoLst = new List<Pipe>();
|
|
public List<FlexPipe> m_FlexPipeInfoLst = new List<FlexPipe>();
|
|
public List<FamilyInstance> m_PipeFittingLst = new List<FamilyInstance>();
|
|
public List<PipingSystem> m_PipingSysLst = new List<PipingSystem>();
|
|
public List<FamilyInstance> m_SpkrLst = new List<FamilyInstance>();
|
|
public List<FamilyInstance> m_PlumbingLst = new List<FamilyInstance>();
|
|
public List<FamilyInstance> m_MachineEquipLst = new List<FamilyInstance>();
|
|
}
|
|
|
|
public class SheetDuctInfo
|
|
{
|
|
public List<Duct> m_DuctInfoLst = new List<Duct>();
|
|
public List<FlexDuct> m_FlexDuctInfoLst = new List<FlexDuct>();
|
|
public List<FamilyInstance> m_DuctFittingLst = new List<FamilyInstance>();
|
|
public List<MEPSystem> m_DuctSysLst = new List<MEPSystem>();
|
|
public List<FamilyInstance> m_DuctAccLst = new List<FamilyInstance>();
|
|
public List<FamilyInstance> m_DuctTerminal = new List<FamilyInstance>();
|
|
}
|
|
|
|
public class SheetETCInfo
|
|
{
|
|
public List<Zone> m_HVACLst = new List<Zone>();
|
|
public List<View> m_ViewLst = new List<View>();
|
|
public List<Material> m_MaterialLst = new List<Material>();
|
|
}
|
|
|
|
}
|
|
}
|