SampleListIfcColumns
Overview
This programming manual in C# offers a practical demonstration of how to create an list of the columns in a model.
Sample code
For example:
Name | Value |
---|
var app = new Beaver.BcadApplication();
var doc = app.ActiveDocument;
if (doc == null)
doc = app.Documents.Add();
var stp = doc.STEPDocument;
var header = new List<string>(); {
header.Add("Name");
header.Add("Profile");
header.Add("Description");
header.Add("Tag");
header.Add("Width");
header.Add("Height");
}
m_gridView.Rows.Clear();
m_gridView.Columns.Clear();
m_gridView.ColumnCount = header.Count;
for (int i = 0; i < m_gridView.ColumnCount; i++) {
m_gridView.Columns[i].HeaderText = header[i];
}
var IfcColumns = BeaverHelper.kInstance.stp.Instnaces.FindInstances("IfcColumn", true);
foreach (STEPInstance IfcColumn in IfcColumns) {
var rec = new List<string>(); {
string Name = IfcColumn.Attributes.AttributeAsStr("Name").Value;
string Description = IfcColumn.Attributes.AttributeAsStr("Description").Value;
string Tag = IfcColumn.Attributes.AttributeAsStr("Tag").Value;
string profile = ""; double Width = 0.0; double Height = 0.0;{
STEPInstance IfcProductDefinitionShape = IfcColumn.Attributes.AttributeAsInst("representation").Value;
if (IfcProductDefinitionShape != null) {
STEPAttributeAggregate IfcShapeRepresentations = IfcProductDefinitionShape.Attributes.AttributeAsAggregate("representations");
if (IfcShapeRepresentations != null) {
bool bFindProfile = false;
foreach (STEPInstance IfcShapeRepresentation in IfcShapeRepresentations.values) {
STEPAttributeAggregate items = IfcShapeRepresentation.Attributes.AttributeAsAggregate("items");
if (items != null) {
foreach (STEPInstance item in items.values) {
if (!item.IsDerivedFrom("IfcExtrudedAreaSolid")) {
continue;
}
var IfcExtrudedAreaSolid = item;
STEPInstance sweptarea = IfcExtrudedAreaSolid.Attributes.AttributeAsInst("sweptarea").Value;
if (sweptarea == null)
continue;
if (sweptarea.IsDerivedFrom("IfcCircleProfileDef")) {
profile = "IfcCircleProfileDef";
var IfcCircleProfileDef = sweptarea;
Width = IfcCircleProfileDef.Attributes.AttributeAsReal("radius").Value;
bFindProfile = true;
break;
} else if (sweptarea.IsDerivedFrom("IfcRectangleProfileDef")) {
profile = "IfcRectangleProfileDef";
var IfcRectangleProfileDef = sweptarea;
Width = IfcRectangleProfileDef.Attributes.AttributeAsReal("xdim").Value;
Height = IfcRectangleProfileDef.Attributes.AttributeAsReal("ydim").Value;
bFindProfile = true;
break;
}
}
}
if (bFindProfile)
break;
}
}
}
}
rec.Add(Name);
rec.Add(profile);
rec.Add(Description);
rec.Add(Tag);
rec.Add(Width.ToString());
rec.Add(Height.ToString());
}
m_gridView.Rows.Add(rec.ToArray());
}