BIM VILLAGE

Version 2.5.2

SampleCreateIfcFooting

Overview

This programming manual in C# offers a practical demonstration of how to create an instance of the IfcFooting class within a model.

Sample code

For example:

Name Value
Name New Footing
Description Description
Tag Tag
Globalid 11dbf1da-7cca-4b99-aaf4-bb134ae32f3c
ObjectType
Ownerhistory IfcOwnerHistory (#15)
ContextOfItems IfcGeometricRepresentationContext (#43)
Storey IfcBuildingStorey (#105) 1\X\8AK
Position 0.000000,0.000000,0.000000
Depth 500
XDim 1200
YDim 1200
ProfileRotateAngle 0
PredefinedType footing_beam
var app = new Beaver.BcadApplication();
var doc = app.ActiveDocument;
if (doc == null)
    doc = app.Documents.Add();
var stp = doc.STEPDocument;
var IfcBuildingStorey  = stp.Instnaces.FindInstance(105);
var IfcFooting = stp.Instnaces.CreateInstance("IfcFooting"); {
	var ObjectPlacement = stp.Instnaces.CreateInstance("IfcLocalPlacement"); {
		var Relativeplacement = stp.Instnaces.CreateInstance("IfcAxis2Placement3D"); {
			var location = stp.Instnaces.CreateInstance("IfcCartesianPoint"); {
				double []values={0,0,0};
				location.Attributes.AttributeAsAggregate("coordinates").values = values;
			}
			var refdirection = stp.Instnaces.CreateInstance("IfcDirection"); {
				double []values={1.0, 0.0, 0.0};
				refdirection.Attributes.AttributeAsAggregate("directionratios").values = values;
			}
			var axis = stp.Instnaces.CreateInstance("IfcDirection"); {
				double []values={0.0, 0.0, 1.0};
				axis.Attributes.AttributeAsAggregate("directionratios").values = values;
			}
			Relativeplacement.Attributes.AttributeAsInst("location").Value = location;
			Relativeplacement.Attributes.AttributeAsInst("refdirection").Value = refdirection;
			Relativeplacement.Attributes.AttributeAsInst("axis").Value = axis;
		}
		STEPInstance placementRelTo = null; {
			var objectplacement = IfcBuildingStorey.Attributes.AttributeAsInst("objectplacement");
			placementRelTo = objectplacement.Value;
		}
		ObjectPlacement.Attributes.AttributeAsInst("PlacementRelTo").Value = placementRelTo;
		ObjectPlacement.Attributes.AttributeAsSelect("Relativeplacement").SetValueAsInst(Relativeplacement);
	}
	var Representation = stp.Instnaces.CreateInstance("IfcProductDefinitionShape"); {
		Representation.Attributes.AttributeAsStr("Name").Value = "";
		Representation.Attributes.AttributeAsStr("Description").Value = "";
		var IfcShapeRepresentation = stp.Instnaces.CreateInstance("IfcShapeRepresentation"); {
			IfcShapeRepresentation.Attributes.AttributeAsInst("ContextOfItems").Value  = stp.Instnaces.FindInstance(43);
			IfcShapeRepresentation.Attributes.AttributeAsStr("RepresentationIdentifier").Value = "Body";
			IfcShapeRepresentation.Attributes.AttributeAsStr("RepresentationType").Value = "SweptSolid";
			var IfcExtrudedAreaSolid = stp.Instnaces.CreateInstance("IfcExtrudedAreaSolid"); {
				var SweptArea = stp.Instnaces.CreateInstance("IfcRectangleProfileDef"); {
					SweptArea.Attributes.AttributeAsStr("ProfileName").Value = "";
					SweptArea.Attributes.AttributeAsReal("XDim").Value = 1200;
					SweptArea.Attributes.AttributeAsReal("YDim").Value = 1200;
					SweptArea.Attributes.AttributeAsEnum("ProfileType").SetValue("AREA");
					var position = stp.Instnaces.CreateInstance("IfcAxis2Placement2D");  {
						var IfcCartesianPoint = stp.Instnaces.CreateInstance("IfcCartesianPoint"); {
							double []values={0.0 , 0.0};
							IfcCartesianPoint.Attributes.AttributeAsAggregate("coordinates").values = values;
						}
						position.Attributes.AttributeAsInst("location").Value = IfcCartesianPoint;
						var IfcDirection = stp.Instnaces.CreateInstance("IfcDirection"); {
							double ang = (180.0 / Math.PI) * 0;
							double []values={Math.Cos(ang), Math.Sin(ang)};
							IfcDirection.Attributes.AttributeAsAggregate("directionratios").values = values;
						}
						position.Attributes.AttributeAsInst("refdirection").Value = IfcDirection;
					}
					SweptArea.Attributes.AttributeAsInst("position").Value = position;
				}
				IfcExtrudedAreaSolid.Attributes.AttributeAsInst("SweptArea").Value = SweptArea;
				var Position = stp.Instnaces.CreateInstance("IfcAxis2Placement3D"); {
					var location = stp.Instnaces.CreateInstance("IfcCartesianPoint"); {
						double []values={0, 0, 0};
						location.Attributes.AttributeAsAggregate("coordinates").values = values;
					}
					var refdirection = stp.Instnaces.CreateInstance("IfcDirection"); {
						double []values={1.0, 0.0, 0.0};
						refdirection.Attributes.AttributeAsAggregate("directionratios").values = values;
					}
					var axis = stp.Instnaces.CreateInstance("IfcDirection"); {
						double []values={0.0, 0.0, 1.0};
						axis.Attributes.AttributeAsAggregate("directionratios").values = values;
					}
					Position.Attributes.AttributeAsInst("location").Value = location;
					Position.Attributes.AttributeAsInst("refdirection").Value = refdirection;
					Position.Attributes.AttributeAsInst("axis").Value = axis;
				}
				IfcExtrudedAreaSolid.Attributes.AttributeAsInst("Position").Value = Position;
				var extrudeddirection = stp.Instnaces.CreateInstance("IfcDirection"); {
					double []values={0, 0, 1};
					extrudeddirection.Attributes.AttributeAsAggregate("directionratios").values = values;
				}
				IfcExtrudedAreaSolid.Attributes.AttributeAsInst("extrudeddirection").Value = extrudeddirection;
				IfcExtrudedAreaSolid.Attributes.AttributeAsReal("Depth").Value = 500;
			}
			STEPInstance []items={IfcExtrudedAreaSolid};
			IfcShapeRepresentation.Attributes.AttributeAsAggregate("Items").values = items;
		}
		STEPInstance []Representations={IfcShapeRepresentation};
		Representation.Attributes.AttributeAsAggregate("Representations").values = Representations;
	}
	IfcFooting.Attributes.AttributeAsStr("Name").Value = "New Footing";
	IfcFooting.Attributes.AttributeAsStr("Description").Value = "Description";
	IfcFooting.Attributes.AttributeAsStr("Tag").Value =  "Tag";
	IfcFooting.Attributes.AttributeAsStr("Globalid").Value =  "11dbf1da-7cca-4b99-aaf4-bb134ae32f3c";
	IfcFooting.Attributes.AttributeAsStr("ObjectType").Value =  "";
	IfcFooting.Attributes.AttributeAsInst("Ownerhistory").Value  = stp.Instnaces.FindInstance(15);
	IfcFooting.Attributes.AttributeAsInst("Representation").Value = Representation;
	IfcFooting.Attributes.AttributeAsInst("ObjectPlacement").Value = ObjectPlacement;
	IfcFooting.Attributes.AttributeAsEnum("PredefinedType").SetValue("footing_beam");
}
{
	STEPInstance IfcRelContainedInSpatialStructure = null; {
		var insts =  FindInstances("IfcRelContainedInSpatialStructure", true);
		foreach (var inst in insts) {
			if (inst.Attributes.AttributeAsInst("relatingstructure").Value == IfcBuildingStorey) {
				IfcRelContainedInSpatialStructure = inst;
				break;
			}
		}
	}
	if (IfcRelContainedInSpatialStructure == null) {
		IfcRelContainedInSpatialStructure = stp.Instnaces.CreateInstance("IfcRelContainedInSpatialStructure");
		IfcRelContainedInSpatialStructure.Attributes.AttributeAsInst("relatingstructure").Value = IfcBuildingStorey;
	}
	var relatedelements = new List<STEPInstance>(); {
		var objs = IfcRelContainedInSpatialStructure.Attributes.AttributeAsAggregate("relatedelements").values;
		if (objs!= null) {
			foreach (STEPInstance obj in objs)
				relatedelements.Add(obj);
		}
		relatedelements.Add(IfcFooting);
	}
	IfcRelContainedInSpatialStructure.Attributes.AttributeAsAggregate("relatedelements").values = relatedelements.ToArray();
}

© 2019 - 2022 BIM VILLAGE.