public double[] getCirpara(Pipe pipe)
{
double[] p=new double[2];
double h=pipe.Diameter;
double b = pipe.Diameter;
p[0] = h;p[1] = b;
return p;
}
public double[] getVolpra(Pipe pipe)
{
double[] p=new double[2];
p[0] = pipe.Width;
p[1] = pipe.Height;
return p;
}
public void getCirPara(Document doc)//按照管径和类型筛选并区分管道
{
ElementId systemTypeId = ElementId.InvalidElementId;
// 获取类型为SupplyAir的系统类型
var systemTypeFilter = new ElementClassFilter(typeof(MEPSystemType));
FilteredElementCollector systemTypes = new FilteredElementCollector(doc);
systemTypes = systemTypes.WherePasses(systemTypeFilter);//全部的类
FilteredElementCollector elements3 = new FilteredElementCollector(doc);
var collectorPipe = elements3.WherePasses(new ElementClassFilter(typeof(Pipe)));
TaskDialog.Show("revit", elements3.GetElementCount().ToString());
FilteredElementCollector pipecurve = collectorPipe.OfClass(typeof(Pipe)).OfCategory(BuiltInCategory.OST_PipeCurves);
double[] para = new double[2];
List<Pipe> pipes = new List<Pipe>();
int yco = 0;
//TaskDialog.Show("revit", numj.ToString());
foreach (Element el in pipecurve)
{
//TaskDialog.Show("revit", "100");
Pipe pipe = el as Pipe;
para = getCirpara(pipe);
//TaskDialog.Show("revit", "函数");
if (pipes.Count == 0)
{
//TaskDialog.Show("revitPIPE", pipes.Count().ToString());
pipes.Add(pipe);
}
//TaskDialog.Show("revitPIPE", pipes.Count().ToString());
//转solid
int re = 0; ;
foreach (var ele in pipes)
{
//TaskDialog.Show("revit", "函数2");
re = 0;
var para0 = getCirpara(ele);
//TaskDialog.Show("revit", "函数3");
if (para0[0] == para[0] && para0[1] == para[1])
{
//TaskDialog.Show("re","4");
re++;
break;
}
}
if (re == 0)
{
yco++;
pipes.Add(pipe);
}
}
TaskDialog.Show("revit", yco.ToString());
TaskDialog.Show("revit", "66");
//2 to 根据各管径类型、参数进行输出
foreach (var systype in systemTypes)
{
var idname = systype.Name;
var idref = systype.Id;//这就是systemTypeID,建模参数之一
TaskDialog.Show("re", idname);
foreach (var pipe in pipes)
{
var pararef = getCirpara(pipe);
foreach (var item in pipecurve)
{
Pipe pipe0 = item as Pipe;
var para0 = getCirpara(pipe0);
var id0 = pipe0.MEPSystem.Name;
if (para0[0] == pararef[0] && para0[1] == para[1])
{
//TaskDialog.Show("re", "进入了第二个循环if");
LocationCurve locationCurve = pipe0.Location as LocationCurve;
if (locationCurve != null)
{
XYZ start0 = locationCurve.Curve.GetEndPoint(0);
XYZ end0 = locationCurve.Curve.GetEndPoint(1);
//把id值和六个坐标值记录下来
/*
wb1.Activate();
wb1.Cells[kk0++, 1] = pipe.Id;
wb1.Cells[kk0, 2] = para0[0];
wb1.Cells[kk0, 3] = para0[1];
wb1.Cells[kk0, 4] = start0.X;
wb1.Cells[kk0, 5] = start0.Y;
wb1.Cells[kk0, 6] = start0.Z;
wb1.Cells[kk0, 7] = end0.X;
wb1.Cells[kk0, 8] = end0.Y;
wb1.Cells[kk0, 9] = end0.Z;
*/
//TaskDialog.Show("revitid", pipe.Id.ToString());
//TaskDialog.Show("revitidref", idref.ToString());
break;//正式运行时需要删除break
}
}
}
}
}
//wb.Save();
TaskDialog.Show("revit", pipecurve.GetElementCount().ToString());