167 lines
6.9 KiB
C#
167 lines
6.9 KiB
C#
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.DB.Plumbing;
|
|
using Autodesk.Revit.UI;
|
|
using KDCS.Utils;
|
|
using KMBIM.Revit.Tools;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
//using COME4Revit.WinForm;
|
|
using System.Windows.Forms;
|
|
|
|
namespace KMBIM
|
|
{
|
|
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
|
class CoilMain : IExternalCommand
|
|
{
|
|
|
|
double cdst = 0, wdst = 0, wdst2 = 0, tdst = 0, xdst = 0, cdia = 0, coffset = 0;
|
|
PipeType cType = null;
|
|
PipingSystemType CsysType = null;
|
|
int m_Mode;
|
|
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
{
|
|
if (!WorkMain.GetInstance().IsValid) return Autodesk.Revit.UI.Result.Succeeded;
|
|
UIApplication uiapp = commandData.Application;
|
|
UIDocument uidoc = uiapp.ActiveUIDocument;
|
|
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
|
|
Document doc = uidoc.Document;
|
|
Autodesk.Revit.Creation.Application creApp = uiapp.Application.Create;
|
|
Autodesk.Revit.Creation.Document creDoc = doc.Create;
|
|
|
|
//test(doc);
|
|
//파이프 유형 리스트에 넣기.
|
|
List<string> m_pipeTypeList = new List<string>();
|
|
|
|
ICollection<Element> Typecollection = new FilteredElementCollector(doc).OfClass(typeof(PipeType)).ToElements();
|
|
foreach (Element elem in Typecollection)
|
|
{
|
|
if (elem is PipeType)
|
|
{
|
|
PipeType pipeType = elem as PipeType;
|
|
m_pipeTypeList.Add(pipeType.Name);
|
|
}
|
|
|
|
}
|
|
|
|
//파이프 시스템 유형 리스트에 넣기.
|
|
List<string> m_pipeSysTypeList = new List<string>();
|
|
ICollection<Element> SysTypeCollection = new FilteredElementCollector(doc).OfClass(typeof(PipingSystemType)).ToElements();
|
|
foreach(Element elem in SysTypeCollection)
|
|
{
|
|
if(elem is PipingSystemType)
|
|
{
|
|
PipingSystemType pipingSystemType = elem as PipingSystemType;
|
|
m_pipeSysTypeList.Add(pipingSystemType.Name);
|
|
}
|
|
}
|
|
|
|
|
|
FormCoil dlg = new FormCoil();
|
|
dlg.doc = doc;
|
|
dlg.CoilDist = 200;//코일간격
|
|
dlg.CoilDistFromWall = 80;//벽에서의 거리
|
|
//dlg.MinCoilDistFromWall = 80;//벽에서의 최소 거리
|
|
//dlg.CoilTotalLenLimit = 100.0;//코일의 총 길이 제한
|
|
dlg.CoilOutAirLenLimit = 8.0;//코일의 외기 길이 제한
|
|
dlg.CoilOffset = 0;//코일 간격띄우기
|
|
dlg.CoilTypeLst = m_pipeTypeList;//코일 유형 리스트
|
|
dlg.CoilSysTypeLst = m_pipeSysTypeList;// 코일 시스템 유형 리스트
|
|
|
|
|
|
|
|
if (dlg.ShowDialog() != DialogResult.OK) return Result.Succeeded;
|
|
/*CoilDist = dlg.CoilDist;
|
|
CoilDistFromWall = dlg.CoilDistFromWall;
|
|
MinCoilDistFromWall = dlg.MinCoilDistFromWall;
|
|
CoilTotalLenLimit = dlg.CoilTotalLenLimit;
|
|
CoilOutAirLenLimit = dlg.CoilOutAirLenLimit;*/
|
|
|
|
cdst = dlg.CoilDist;
|
|
wdst = dlg.CoilDistFromWall;
|
|
//wdst2 = dlg.MinCoilDistFromWall;
|
|
//tdst = dlg.CoilTotalLenLimit;
|
|
xdst = dlg.CoilOutAirLenLimit;
|
|
cdia = dlg.CoilDiameter;
|
|
coffset = dlg.CoilOffset;
|
|
cType = dlg.CoilType;
|
|
CsysType = dlg.CoilSysType;
|
|
|
|
m_Mode = dlg.ListIndex;
|
|
//Transaction transaction = new Transaction(doc, "Create Heating Coil");
|
|
//transaction.Start();
|
|
|
|
if (m_Mode == 0)
|
|
{
|
|
CM_TORCOIL1 m_TOLCOIL1 = new CM_TORCOIL1();
|
|
bool nb_tor = m_TOLCOIL1.DrawTorCoil1(uiapp, cdst, wdst, wdst2, tdst, xdst, coffset, cdia, cType, CsysType);
|
|
|
|
}
|
|
else if (m_Mode == 1)
|
|
{
|
|
CM_TORCOIL2 m_TOLCOIL2 = new CM_TORCOIL2();
|
|
bool nb_tor = m_TOLCOIL2.DrawTorCoil2(uiapp, cdst, wdst, wdst2, tdst, xdst, coffset, cdia, cType, CsysType);
|
|
}
|
|
else if (m_Mode == 2)
|
|
{
|
|
CM_OUTCOIL m_OUTCOIL = new CM_OUTCOIL();
|
|
bool nb_out = m_OUTCOIL.DrawOutCoil(uiapp, cdst, wdst, wdst2, tdst, xdst, coffset, cdia ,cType, CsysType);
|
|
}
|
|
|
|
|
|
//transaction.Commit();
|
|
|
|
return Result.Succeeded;
|
|
}
|
|
|
|
public void test(Document doc)
|
|
{
|
|
BuiltInParameter pipeSegmentParam = BuiltInParameter.RBS_PIPE_SEGMENT_PARAM;
|
|
BuiltInParameter pipeLengthParam = BuiltInParameter.INSTANCE_LENGTH_PARAM;
|
|
|
|
// Get all pipes in the project
|
|
FilteredElementCollector collectorPipes = new FilteredElementCollector(doc);
|
|
collectorPipes.OfClass(typeof(Autodesk.Revit.DB.Plumbing.Pipe));
|
|
IEnumerable<Pipe> pipes = collectorPipes.ToElements().Cast<Pipe>();
|
|
|
|
|
|
FilteredElementCollector collectorPipeType = new FilteredElementCollector(doc);
|
|
collectorPipeType.OfClass(typeof(Segment));
|
|
|
|
IEnumerable<Segment> segments = collectorPipeType.ToElements().Cast<Segment>();
|
|
foreach (Segment segment in segments)
|
|
{
|
|
StringBuilder strPipeInfo = new StringBuilder();
|
|
strPipeInfo.AppendLine("Segment: " + segment.Name);
|
|
|
|
strPipeInfo.AppendLine("Roughness: " + segment.Roughness);
|
|
|
|
strPipeInfo.AppendLine("Pipe Sizes:");
|
|
//double dLengthFac = 12; // used to convert stored units, 304.8 for Imperial to Metric, 12 for Imperial
|
|
foreach (MEPSize size in segment.GetSizes())
|
|
{
|
|
double totalLength = 0.0;
|
|
foreach (Pipe pipe in pipes)
|
|
{
|
|
Parameter pipeSegment = pipe.get_Parameter(pipeSegmentParam);
|
|
double pipeSize = pipe.Diameter;
|
|
if (pipeSegment.AsString() == segment.Name.ToString())
|
|
{
|
|
if (pipeSize == size.NominalDiameter)
|
|
{
|
|
totalLength = totalLength + pipe.get_Parameter(pipeLengthParam).AsDouble();
|
|
}
|
|
}
|
|
}
|
|
strPipeInfo.AppendLine(string.Format("Nominal: {0:F3}", Unit.FeetToMM(size.NominalDiameter)));
|
|
//strPipeInfo.AppendLine(string.Format("Nominal: {0:F3}",Unit.CovertFromAPI(DisplayUnitType.DUT_MILLIMETERS,size.NominalDiameter)));
|
|
}
|
|
|
|
TaskDialog.Show("PipeSetting Data", strPipeInfo.ToString());
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|