SampleRemoveBuildingElement
Overview
This programming manual in C# offers a practical demonstration of how to remove an instance of the IfcBuildingElement class within a model.
Sample code
For example:
Name | Value |
---|---|
BuildingElementForRemove | IfcWallStandardCase (#254) New Wall |
var app = new Beaver.BcadApplication();
var doc = app.ActiveDocument;
if (doc == null)
doc = app.Documents.Add();
var stp = doc.STEPDocument;
var removeInst = stp.Instnaces.FindInstance(254);
stp.Instnaces.DeleteInstance(removeInst);
var IfcRelContainedInSpatialStructures = stp.Instnaces.FindInstances("IfcRelContainedInSpatialStructure", true);
foreach (ISTEPInstance IfcRelContainedInSpatialStructure in IfcRelContainedInSpatialStructures) {
var RelatedElements = IfcRelContainedInSpatialStructure.Attributes.AttributeAsAggregate("RelatedElements");
for (int i = 0; i < RelatedElements.values.Length; i++) {
if (RelatedElements.values[i].Id == removeInst.Id) {
RelatedElements.DeleteByIndex(i);
break;
}
}
}
foreach (object view in doc.Views) {
var view3D = view as BcadView3D;
if (view3D != null)
view3D.Redraw();
}