ElementIterator iteratore = Application.ActiveDocument.get_Elements(typeof(ReferencePoint));
int count = 0;
while (iteratore.MoveNext())
{
int update = ++count;
string name = update.ToString();
Autodesk.Revit.Element elemento = iteratore.Current as Autodesk.Revit.Element;
ReferencePoint elementoSel = elemento as ReferencePoint;
Parameter par = elementoSel.get_Parameter("Nome");
par.Set(name);
}
Document doc = Application.ActiveDocument;
List<DataFrame> data = new List<DataFrame>();
ElementIterator iterator = doc.get_Elements(typeof(CurveByPoints));
iterator.Reset();
while (iterator.MoveNext())
{
CurveByPoints LineMod = iterator.Current as CurveByPoints;
Line line = LineMod.GeometryCurve as Line;
ReferencePointArray points = LineMod.GetPoints();
string bar = LineMod.Id.Value.ToString();
ReferencePoint point1 = points[0];
string node1 = point1.get_Parameter("Nome").AsString();
ReferencePoint point2 = points[1];
string node2 = point2.get_Parameter("Nome").AsString();
double ConvMeter = 0.3048;
int approx = 4;
string Lenght = (Math.Round((line.Length)*ConvMeter,approx)).ToString();
data.Add(new DataFrame(bar,node1,Lenght,node2));
}
formConnectorData connector = new formConnectorData(data);
connector.ShowDialog();
public class DataFrame
{
string _Bar;
string _FirstNode;
string _Lenght;
string _SecondNode;
public DataFrame(string Bar, string FirstNode, string Lenght, string SecondNode)
{
_Bar =Bar;
_FirstNode = FirstNode;
_Lenght = Lenght;
_SecondNode = SecondNode;
}
public string Bar
{
get { return _Bar; }
}
public string from_Node
{
get { return _FirstNode; }
}
public string Lenght
{
get { return _Lenght; }
}
public string to_Node
{
get { return _SecondNode; }
}
}
public partial class formConnectorData : Form
{
public formConnectorData(List<DataFrame> a)
{
InitializeComponent();
dataGridView1.DataSource = a;
}
}