SampleCreateIfcSite
Overview
This programming manual in C# offers a practical demonstration of how to create an instance of the IfcSite class within a model.
Sample code
For example:
Name | Value |
---|---|
Name | New Site |
LongName | |
Description | description |
Project | |
Ownerhistory | |
CompositionType |
var app = new Beaver.BcadApplication();
var doc = app.ActiveDocument;
if (doc == null)
doc = app.Documents.Add();
var stp = doc.STEPDocument;
var IfcProject = stp.Instnaces.FindInstance(-1);
var IfcSite = stp.Instnaces.CreateInstance("IfcSite"); {
IfcSite.Attributes.AttributeAsInst("Ownerhistory").Value = stp.Instnaces.FindInstance(-1);
IfcSite.Attributes.AttributeAsStr("Description").Value = "description";
IfcSite.Attributes.AttributeAsStr("Name").Value = "New Site";
IfcSite.Attributes.AttributeAsStr("LongName").Value = "";
IfcSite.Attributes.AttributeAsEnum("CompositionType").SetValue(Config.kInstance.CompositionType.SelectedValue);
}
{
STEPInstance IfcRelAggregates = null; {
var insts = FindInstances("IfcRelAggregates", true);
foreach (var inst in insts) {
if (inst.Attributes.AttributeAsInst("RelatingObject").Value == IfcProject) {
IfcRelAggregates = inst;
break;
}
}
}
if (IfcRelAggregates == null) {
IfcRelAggregates = stp.Instnaces.CreateInstance("IfcRelAggregates");
IfcRelAggregates.Attributes.AttributeAsInst("RelatingObject").Value = IfcProject;
}
var RelatedObjects = new List<STEPInstance>(); {
var objs = IfcRelAggregates.Attributes.AttributeAsAggregate("RelatedObjects").values;
if (objs!= null) {
foreach (STEPInstance obj in objs)
RelatedObjects.Add(obj);
}
RelatedObjects.Add(IfcSite);
}
IfcRelAggregates.Attributes.AttributeAsAggregate("RelatedObjects").values = RelatedObjects.ToArray();
}