Skip to content

Instantly share code, notes, and snippets.

@josinSbazin
Created January 10, 2018 15:17
Show Gist options
  • Save josinSbazin/a8e7f3a9f320cd33db608669d0387c3a to your computer and use it in GitHub Desktop.
Save josinSbazin/a8e7f3a9f320cd33db608669d0387c3a to your computer and use it in GitHub Desktop.
create_parametric_section_lira
public int Create_beam_parametric_section(FamilySymbol _family_symbol)
{
if (_family_symbol == null)
return -1;
List<IPrimitive> primitiveList = new List<IPrimitive>();
List<Vertex3>[] A_0 = (List<Vertex3>[]) null;
GeometryElement geometry = ((Autodesk.Revit.DB.Element) _family_symbol).get_Geometry(new Options());
string str = ((Autodesk.Revit.DB.Element) _family_symbol).get_Parameter((BuiltInParameter) -1010105).AsString();
IEnumerator enumerator1 = (IEnumerator) geometry.GetEnumerator();
bool flag1 = false;
if (!this.CheckBeamGeometry(geometry))
return -1;
enumerator1.Reset();
while (enumerator1.MoveNext())
{
GeometryObject current1 = (GeometryObject) enumerator1.Current;
if (current1 is Solid)
{
IEnumerator enumerator2 = ((Solid) current1).get_Faces().GetEnumerator();
bool flag2 = true;
enumerator2.Reset();
if (enumerator2.MoveNext())
{
Face current2 = (Face) enumerator2.Current;
if (current2 is PlanarFace)
{
PlanarFace planarFace = (PlanarFace) current2;
EdgeArrayArray edgeLoops = ((Face) planarFace).get_EdgeLoops();
double[] numArray = new double[3]
{
planarFace.get_Origin().get_X(),
planarFace.get_Origin().get_Y(),
planarFace.get_Origin().get_Z()
};
A_0 = new List<Vertex3>[edgeLoops.get_Size()];
for (int index1 = 0; index1 < edgeLoops.get_Size(); ++index1)
{
EdgeArray edgeArray = edgeLoops.get_Item(index1);
List<Vertex3> _contour = new List<Vertex3>();
IEnumerator enumerator3 = edgeArray.GetEnumerator();
try
{
enumerator3.Reset();
while (enumerator3.MoveNext())
{
IList<XYZ> xyzList = ((Edge) enumerator3.Current).Tessellate();
for (int index2 = 0; index2 < ((ICollection<XYZ>) xyzList).Count; ++index2)
{
XYZ xyz = xyzList[index2];
if (Math.Abs(xyz.get_X() - numArray[0]) > 1E-06)
numArray[0] = double.MaxValue;
if (Math.Abs(xyz.get_Y() - numArray[1]) > 1E-06)
numArray[1] = double.MaxValue;
if (Math.Abs(xyz.get_Z() - numArray[2]) > 1E-06)
numArray[2] = double.MaxValue;
if (!((IEnumerable<double>) numArray).All<double>((Func<double, bool>) (elem => elem == double.MaxValue)))
_contour.Add(new Vertex3(UnitUtils.ConvertFromInternalUnits(xyz.get_X(), (DisplayUnitType) 0), UnitUtils.ConvertFromInternalUnits(xyz.get_Y(), (DisplayUnitType) 0), UnitUtils.ConvertFromInternalUnits(xyz.get_Z(), (DisplayUnitType) 0)));
else
break;
}
}
}
catch (Exception ex)
{
_contour = (List<Vertex3>) null;
}
if (_contour.Count != 0)
{
e_Load_Acxis_Location _location = e_Load_Acxis_Location.LAL_Z;
if (numArray[0] != double.MaxValue)
_location = e_Load_Acxis_Location.LAL_X;
if (numArray[1] != double.MaxValue)
_location = e_Load_Acxis_Location.LAL_Y;
if (numArray[2] != double.MaxValue)
_location = e_Load_Acxis_Location.LAL_Z;
List<Vertex3> vertex3List;
if (flag2)
{
vertex3List = CExportToLira.Optimization_countour(_contour, _location, true);
flag2 = false;
}
else
vertex3List = CExportToLira.Optimization_countour(_contour, _location, false);
A_0[index1] = vertex3List;
}
}
if (A_0.Length != 0)
{
if (A_0.Length <= 2)
{
try
{
List<Vertex3> first_vertex_arr = new List<Vertex3>();
List<Vertex3>[] vertex3ListArray = new List<Vertex3>[A_0.Length];
for (int index1 = 0; index1 < A_0.Length; ++index1)
{
List<Vertex3> vertex3List1 = A_0[index1];
if (vertex3List1.Count != 0)
{
double y_max = vertex3List1[0].Y;
List<Vertex3> vertex3List2 = new List<Vertex3>();
foreach (Vertex3 vertex3 in vertex3List1)
{
if (y_max <= vertex3.Y)
y_max = vertex3.Y;
}
List<Vertex3> all = vertex3List1.FindAll((Predicate<Vertex3>) (e => Math.Abs(e.Y - y_max) < 1E-06));
double x = all[0].X;
foreach (Vertex3 vertex3 in all)
{
if (x >= vertex3.X)
x = vertex3.X;
}
first_vertex_arr.Add(new Vertex3(x, y_max, 0.0));
}
int index2 = vertex3List1.FindIndex((Predicate<Vertex3>) (e =>
{
if (Math.Abs(e.X - first_vertex_arr[first_vertex_arr.Count - 1].X) < 1E-06)
return Math.Abs(e.Y - first_vertex_arr[first_vertex_arr.Count - 1].Y) < 1E-06;
return false;
}));
List<Vertex3> vertex3List3 = new List<Vertex3>();
for (int index3 = index2; index3 < vertex3List1.Count; ++index3)
vertex3List3.Add(vertex3List1[index3]);
for (int index3 = 0; index3 < index2; ++index3)
vertex3List3.Add(vertex3List1[index3]);
vertex3ListArray[index1] = vertex3List3;
}
A_0 = vertex3ListArray;
flag1 = true;
}
catch (Exception ex)
{
this.add_error_warning_message(e_Message.icon_error, "Не удалось преобразовать сечение к параметрическому виду", ((object) ((Autodesk.Revit.DB.Element) _family_symbol).get_Id()).ToString());
flag1 = false;
}
}
}
}
}
}
}
if (flag1)
{
if (A_0.Length == 2)
{
if (A_0[0].Count == 4 && A_0[1].Count == 4)
{
List<Vertex3> vertex3List1 = A_0[0];
List<Vertex3> vertex3List2 = A_0[1];
if (this.is_parallel(vertex3List1[0], vertex3List1[3], vertex3List1[1], vertex3List1[2]) && this.is_parallel(vertex3List1[0], vertex3List1[1], vertex3List1[3], vertex3List1[2]) && (this.is_perpendicular(vertex3List1[0], vertex3List1[3], vertex3List1[0], vertex3List1[1]) && this.is_parallel(vertex3List2[0], vertex3List2[1], vertex3List2[3], vertex3List2[2])) && (this.is_parallel(vertex3List2[0], vertex3List2[3], vertex3List2[1], vertex3List2[2]) && this.is_perpendicular(vertex3List2[0], vertex3List2[3], vertex3List2[0], vertex3List2[1])))
{
SectionBarBox sectionBarBox = new SectionBarBox(this.m_model.getSectionContainer());
sectionBarBox.setB(this.get_line_length(vertex3List1[0], vertex3List1[3]));
sectionBarBox.setH(this.get_line_length(vertex3List1[0], vertex3List1[1]));
sectionBarBox.setb((this.get_line_length(vertex3List1[0], vertex3List1[3]) - this.get_line_length(vertex3List2[0], vertex3List2[3])) / 2.0);
sectionBarBox.seth((this.get_line_length(vertex3List1[0], vertex3List1[1]) - this.get_line_length(vertex3List2[0], vertex3List2[1])) / 2.0);
sectionBarBox.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarBox.TypeSectionName = false;
sectionBarBox.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarBox);
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarBox.getIndex());
return sectionBarBox.getIndex();
}
}
else
{
List<Vertex3> source1 = A_0[0];
List<Vertex3> source2 = A_0[1];
double num1 = source1.Sum<Vertex3>((Func<Vertex3, double>) (e => e.X));
double num2 = source1.Sum<Vertex3>((Func<Vertex3, double>) (e => e.Y));
Vertex3 _start1 = new Vertex3(Math.Round(num1 / (double) source1.Count, 6), Math.Round(num2 / (double) source1.Count, 6), source1[0].Z);
double num3 = source2.Sum<Vertex3>((Func<Vertex3, double>) (e => e.X));
double num4 = source2.Sum<Vertex3>((Func<Vertex3, double>) (e => e.Y));
Vertex3 _start2 = new Vertex3(Math.Round(num3 / (double) source2.Count, 6), Math.Round(num4 / (double) source2.Count, 6), source2[0].Z);
if (this.get_line_length(_start1, source1[0]) - this.get_line_length(_start1, source1[source1.Count / 2]) < 1E-06 && this.get_line_length(_start2, source2[0]) - this.get_line_length(_start2, source2[source2.Count / 2]) < 1E-06)
{
double lineLength1 = this.get_line_length(_start1, source1[0]);
double lineLength2 = this.get_line_length(_start2, source2[0]);
SectionBarRing sectionBarRing = new SectionBarRing(this.m_model.getSectionContainer());
sectionBarRing.setD(Math.Abs(Math.Round(2.0 * lineLength1, 6)));
sectionBarRing.setd(Math.Abs(Math.Round(2.0 * lineLength2, 6)));
sectionBarRing.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarRing.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarRing);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarRing.getIndex());
return sectionBarRing.getIndex();
}
}
}
else
{
List<Vertex3> source = A_0[0];
if (source.Count == 4 && this.is_parallel(source[0], source[3], source[1], source[2]) && (this.is_parallel(source[0], source[1], source[3], source[2]) && this.is_perpendicular(source[0], source[3], source[0], source[1])))
{
SectionBarRect sectionBarRect = new SectionBarRect(this.m_model.getSectionContainer());
sectionBarRect.setB(this.get_line_length(source[0], source[3]));
sectionBarRect.setH(this.get_line_length(source[0], source[1]));
sectionBarRect.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarRect.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarRect);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarRect.getIndex());
return sectionBarRect.getIndex();
}
if (source.Count == 6 && this.is_parallel(source[0], source[5], source[1], source[2]) && (this.is_parallel(source[1], source[2], source[4], source[3]) && this.is_parallel(source[0], source[1], source[5], source[4])) && (this.is_parallel(source[5], source[4], source[2], source[3]) && this.is_perpendicular(source[0], source[1], source[1], source[2]) && this.is_perpendicular(source[5], source[4], source[4], source[3])))
{
if (this.get_line_length(source[0], source[1]) > this.get_line_length(source[5], source[4]))
{
SectionBarCorner sectionBarCorner = new SectionBarCorner(this.m_model.getSectionContainer());
sectionBarCorner.setH(this.get_line_length(source[0], source[1]));
sectionBarCorner.seth(this.get_line_length(source[2], source[3]));
sectionBarCorner.setB(this.get_line_length(source[1], source[2]));
sectionBarCorner.setb(this.get_line_length(source[0], source[5]));
sectionBarCorner.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarCorner.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarCorner);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarCorner.getIndex());
return sectionBarCorner.getIndex();
}
SectionBarCorner sectionBarCorner1 = new SectionBarCorner(this.m_model.getSectionContainer());
sectionBarCorner1.setH(this.get_line_length(source[5], source[4]));
sectionBarCorner1.seth(this.get_line_length(source[2], source[3]));
sectionBarCorner1.setB(this.get_line_length(source[3], source[4]));
sectionBarCorner1.setb(this.get_line_length(source[0], source[5]));
sectionBarCorner1.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarCorner1.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarCorner1);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarCorner1.getIndex());
return sectionBarCorner1.getIndex();
}
if (A_0[0].Count == 8)
{
if (this.get_line_length(source[0], source[1]) != this.get_line_length(source[7], source[6]))
{
if (this.is_parallel(source[0], source[7], source[1], source[2]) && this.is_parallel(source[5], source[6], source[4], source[3]) && (this.is_parallel(source[0], source[1], source[5], source[4]) && this.is_perpendicular(source[0], source[1], source[1], source[2])) && (this.is_perpendicular(source[0], source[1], source[0], source[7]) && this.is_perpendicular(source[5], source[4], source[4], source[3]) && (this.is_perpendicular(source[7], source[6], source[6], source[5]) && this.is_perpendicular(source[2], source[3], source[3], source[4]))) && this.get_line_length(source[6], source[7]) == this.get_line_length(source[3], source[2]))
{
SectionBarShv sectionBarShv = new SectionBarShv(this.m_model.getSectionContainer());
sectionBarShv.setB(this.get_line_length(source[1], source[2]));
sectionBarShv.setb(this.get_line_length(source[0], source[7]) - this.get_line_length(source[5], source[5]));
sectionBarShv.setH(this.get_line_length(source[0], source[1]));
sectionBarShv.seth(this.get_line_length(source[2], source[3]));
sectionBarShv.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarShv.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarShv);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarShv.getIndex());
return sectionBarShv.getIndex();
}
if (this.is_parallel(source[0], source[7], source[5], source[6]) && this.is_parallel(source[1], source[2], source[4], source[3]) && (this.is_parallel(source[7], source[6], source[2], source[3]) && this.is_perpendicular(source[0], source[7], source[7], source[6])) && (this.is_perpendicular(source[5], source[6], source[6], source[7]) && this.is_perpendicular(source[2], source[3], source[3], source[4]) && (this.is_perpendicular(source[1], source[2], source[2], source[3]) && this.is_perpendicular(source[5], source[4], source[4], source[3]))) && this.get_line_length(source[0], source[1]) == this.get_line_length(source[4], source[5]))
{
SectionBarShv sectionBarShv = new SectionBarShv(this.m_model.getSectionContainer());
sectionBarShv.setB(this.get_line_length(source[5], source[1]));
sectionBarShv.setb(this.get_line_length(source[0], source[7]) - this.get_line_length(source[1], source[2]));
sectionBarShv.setH(this.get_line_length(source[7], source[6]));
sectionBarShv.seth(this.get_line_length(source[4], source[5]));
sectionBarShv.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarShv.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarShv);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarShv.getIndex());
return sectionBarShv.getIndex();
}
}
else if (this.is_parallel(source[0], source[7], source[3], source[4]) && this.is_parallel(source[0], source[1], source[7], source[6]) && (this.is_parallel(source[2], source[3], source[5], source[4]) && this.is_perpendicular(source[0], source[7], source[0], source[1])) && (this.is_perpendicular(source[1], source[2], source[2], source[3]) && this.is_perpendicular(source[2], source[3], source[3], source[4]) && (this.is_perpendicular(source[4], source[5], source[5], source[6]) && this.is_perpendicular(source[6], source[7], source[7], source[0]))) && (this.get_line_length(source[6], source[7]) == this.get_line_length(source[0], source[1]) && this.get_line_length(source[2], source[3]) == this.get_line_length(source[5], source[4])))
{
if (this.get_line_length(source[1], source[2]) == this.get_line_length(source[5], source[6]))
{
if (this.get_line_length(source[0], source[7]) > this.get_line_length(source[3], source[4]))
{
ISectionBarTavrSymetr_T sectionBarTavrSymetrT = (ISectionBarTavrSymetr_T) new SectionBarTavrSymetr_T(this.m_model.getSectionContainer());
sectionBarTavrSymetrT.setH(Math.Abs(Math.Round(source[0].Y - source[3].Y, 6)));
sectionBarTavrSymetrT.seth(this.get_line_length(source[0], source[1]));
sectionBarTavrSymetrT.setB(this.get_line_length(source[0], source[7]));
sectionBarTavrSymetrT.setb(this.get_line_length(source[3], source[4]));
sectionBarTavrSymetrT.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarTavrSymetrT.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarTavrSymetrT);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarTavrSymetrT.getIndex());
return sectionBarTavrSymetrT.getIndex();
}
SectionBarTavrSymetr_L sectionBarTavrSymetrL = new SectionBarTavrSymetr_L(this.m_model.getSectionContainer());
sectionBarTavrSymetrL.setH(Math.Abs(Math.Round(source[0].Y - source[3].Y, 6)));
sectionBarTavrSymetrL.seth(this.get_line_length(source[2], source[3]));
sectionBarTavrSymetrL.setB(this.get_line_length(source[3], source[4]));
sectionBarTavrSymetrL.setb(this.get_line_length(source[0], source[7]));
sectionBarTavrSymetrL.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarTavrSymetrL.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarTavrSymetrL);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarTavrSymetrL.getIndex());
return sectionBarTavrSymetrL.getIndex();
}
if (this.get_line_length(source[0], source[7]) > this.get_line_length(source[3], source[4]))
{
SectionBarTavrNonSymetr_T barTavrNonSymetrT = new SectionBarTavrNonSymetr_T(this.m_model.getSectionContainer());
barTavrNonSymetrT.setH(this.get_line_length(source[0], source[1]) + this.get_line_length(source[2], source[3]));
barTavrNonSymetrT.seth(this.get_line_length(source[0], source[1]));
barTavrNonSymetrT.setB(this.get_line_length(source[0], source[7]));
barTavrNonSymetrT.setb(this.get_line_length(source[3], source[4]));
barTavrNonSymetrT.setb1(this.get_line_length(source[5], source[6]) + this.get_line_length(source[3], source[4]) / 2.0);
barTavrNonSymetrT.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
barTavrNonSymetrT.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) barTavrNonSymetrT);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), barTavrNonSymetrT.getIndex());
return barTavrNonSymetrT.getIndex();
}
SectionBarTavrNonSymetr_L barTavrNonSymetrL = new SectionBarTavrNonSymetr_L(this.m_model.getSectionContainer());
barTavrNonSymetrL.setH(this.get_line_length(source[0], source[1]) + this.get_line_length(source[2], source[3]));
barTavrNonSymetrL.seth(this.get_line_length(source[2], source[3]));
barTavrNonSymetrL.setB(this.get_line_length(source[3], source[4]));
barTavrNonSymetrL.setb(this.get_line_length(source[0], source[7]));
barTavrNonSymetrL.setb1(this.get_line_length(source[5], source[6]) + this.get_line_length(source[0], source[7]) / 2.0);
barTavrNonSymetrL.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
barTavrNonSymetrL.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) barTavrNonSymetrL);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), barTavrNonSymetrL.getIndex());
return barTavrNonSymetrL.getIndex();
}
}
if (A_0[0].Count == 12)
{
if (this.get_line_length(source[0], source[11]) > this.get_line_length(source[2], source[9]))
{
if (this.is_parallel(source[0], source[11], source[5], source[6]) && this.is_parallel(source[0], source[1], source[11], source[10]) && (this.is_parallel(source[1], source[2], source[4], source[3]) && this.is_parallel(source[9], source[10], source[8], source[7])) && (this.is_parallel(source[2], source[3], source[9], source[8]) && this.is_parallel(source[4], source[5], source[7], source[6]) && (this.is_perpendicular(source[0], source[1], source[0], source[11]) && this.is_perpendicular(source[1], source[2], source[2], source[3]))) && (this.is_perpendicular(source[2], source[3], source[3], source[4]) && this.is_perpendicular(source[4], source[5], source[5], source[6]) && (this.is_perpendicular(source[6], source[7], source[7], source[8]) && this.is_perpendicular(source[8], source[9], source[9], source[10])) && (this.is_perpendicular(source[9], source[10], source[10], source[11]) && this.is_perpendicular(source[0], source[11], source[11], source[10]))))
{
SectionBarDvutavr sectionBarDvutavr = new SectionBarDvutavr(this.m_model.getSectionContainer());
sectionBarDvutavr.setb1(this.get_line_length(source[5], source[6]));
sectionBarDvutavr.setb2(this.get_line_length(source[0], source[11]));
sectionBarDvutavr.setH(this.get_line_length(source[0], source[5]));
sectionBarDvutavr.seth1(this.get_line_length(source[4], source[5]));
sectionBarDvutavr.seth2(this.get_line_length(source[0], source[1]));
sectionBarDvutavr.setb(this.get_line_length(source[3], source[8]));
sectionBarDvutavr.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarDvutavr.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarDvutavr);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarDvutavr.getIndex());
return sectionBarDvutavr.getIndex();
}
}
else if (this.is_parallel(new Vertex3[12]
{
source[0],
source[11],
source[5],
source[6],
source[2],
source[1],
source[3],
source[4],
source[10],
source[9],
source[7],
source[8]
}))
{
if (this.is_parallel(new Vertex3[12]
{
source[0],
source[1],
source[11],
source[10],
source[2],
source[3],
source[9],
source[8],
source[4],
source[5],
source[7],
source[6]
}) && this.is_perpendicular(source[0], source[1], source[1], source[2]))
{
SectionBarCross sectionBarCross = new SectionBarCross(this.m_model.getSectionContainer());
sectionBarCross.setH(this.get_line_length(source[0], source[5]));
sectionBarCross.seth(this.get_line_length(source[2], source[3]));
sectionBarCross.seth1(this.get_line_length(source[0], source[1]) + this.get_line_length(source[2], source[3]) / 2.0);
sectionBarCross.setB(this.get_line_length(source[2], source[9]));
sectionBarCross.setb(this.get_line_length(source[0], source[11]));
sectionBarCross.setb1(this.get_line_length(source[2], source[1]) + this.get_line_length(source[0], source[11]) / 2.0);
sectionBarCross.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarCross.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarCross);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarCross.getIndex());
return sectionBarCross.getIndex();
}
}
}
else
{
double num1 = source.Sum<Vertex3>((Func<Vertex3, double>) (e => e.X));
double num2 = source.Sum<Vertex3>((Func<Vertex3, double>) (e => e.Y));
Vertex3 _start = new Vertex3(Math.Round(num1 / (double) source.Count, 6), Math.Round(num2 / (double) source.Count, 6), source[0].Z);
if (this.get_line_length(_start, source[0]) - this.get_line_length(_start, source[source.Count / 2]) < 1E-06 && this.get_line_length(_start, source[0]) - this.get_line_length(_start, source[1]) < 1E-06)
{
double lineLength = this.get_line_length(_start, source[0]);
SectionBarRing sectionBarRing = new SectionBarRing(this.m_model.getSectionContainer());
sectionBarRing.setD(Math.Abs(Math.Round(2.0 * lineLength, 6)));
sectionBarRing.setd(0.0);
sectionBarRing.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarRing.setComents(str);
this.m_model.getSectionContainer().addSection((ISection) sectionBarRing);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarRing.getIndex());
return sectionBarRing.getIndex();
}
}
}
}
IPrimitive primitive = (IPrimitive) new Polygon(A_0);
primitiveList.Add(primitive);
SectionBarCustom sectionBarCustom1 = new SectionBarCustom(this.m_model.getSectionContainer());
sectionBarCustom1.setName(((Autodesk.Revit.DB.Element) _family_symbol).get_Name());
sectionBarCustom1.setComents(str);
sectionBarCustom1.getData().set_data(primitiveList);
ISectionBarCustom sectionBarCustom2 = (ISectionBarCustom) sectionBarCustom1;
CustomSectionCalculation calc = new CustomSectionCalculation();
if (calc.calculate(primitiveList))
sectionBarCustom2.getData().set_calculation(calc);
if (!this.section_dict.ContainsKey(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue()))
{
this.m_model.getSectionContainer().addSection((ISection) sectionBarCustom2);
this.section_dict.Add(((Autodesk.Revit.DB.Element) _family_symbol).get_Id().get_IntegerValue(), sectionBarCustom2.getIndex());
}
return sectionBarCustom2.getIndex();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment