-
Notifications
You must be signed in to change notification settings - Fork 0
/
PaintFramebyFaces.cs
75 lines (56 loc) · 2.21 KB
/
PaintFramebyFaces.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
public void paintFrame ()
{
UIDocument uidoc = this.ActiveUIDocument;
Document Documento = uidoc.Document;
/*
FilteredElementCollector Trabes = new FilteredElementCollector(Documento).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralFraming);
string nombre = "";
foreach(Element Trabe in Trabes)
{
nombre += Trabe.Name;
}
TaskDialog.Show("Resultado",nombre);
*/
//LINQ
List<Element> trabes = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance))
.OfCategory(BuiltInCategory.OST_StructuralFraming)
.Where(el => el.Name == "TRABES_PORTANTES_ITISA")
.OrderBy(el => el.Id)
.ToList();
Element trabe = Documento.GetElement(uidoc.Selection.PickObject(ObjectType.Element));
List<Face> caras = new List<Face>();
foreach (GeometryInstance geometryObject in trabe.get_Geometry(new Options ()))
{
if (geometryObject != null)
{
GeometryElement geo = geometryObject.GetInstanceGeometry();
foreach(GeometryObject abc in geo)
{
Solid Solido = abc as Solid;
foreach(Face carass in Solido.Faces)
{
caras.Add(carass);
}
}
}
}
string tex = "";
List<double> Areas = new List<double>();
foreach (Face cara in caras)
{
Areas.Add(UnitUtils.ConvertFromInternalUnits(cara.Area, DisplayUnitType.DUT_SQUARE_METERS));
if(Documento.IsPainted(trabe.Id,cara))
{
var area = UnitUtils.ConvertFromInternalUnits(cara.Area, DisplayUnitType.DUT_SQUARE_METERS);
tex += "La cara esta pintada" + " " + area.ToString() + Environment.NewLine;
}
else
{
var area = UnitUtils.ConvertFromInternalUnits(cara.Area, DisplayUnitType.DUT_SQUARE_METERS);
tex += "La cara NO esta pintada" + " " + area.ToString() + Environment.NewLine;
}
}
string Resultado = Areas.Sum().ToString();
TaskDialog.Show ("Resultados", Resultado);
}
}