2020-12-08 10:58:20 +03:00
|
|
|
|
using GeometryGym.Ifc;
|
2020-12-08 10:25:46 +03:00
|
|
|
|
using GeometryGym.STEP;
|
2020-12-08 10:58:20 +03:00
|
|
|
|
using System.Collections.Generic;
|
2020-09-14 23:23:17 +03:00
|
|
|
|
|
|
|
|
|
namespace ConsoleCreateSpanAnnotation
|
|
|
|
|
{
|
2020-12-08 10:58:20 +03:00
|
|
|
|
internal class Program
|
2020-09-14 23:23:17 +03:00
|
|
|
|
{
|
2020-12-08 10:58:20 +03:00
|
|
|
|
private static void Main(string[] args)
|
2020-09-14 23:23:17 +03:00
|
|
|
|
{
|
|
|
|
|
var database = new DatabaseIfc(ModelView.Ifc4X3NotAssigned);
|
2020-12-02 20:59:14 +03:00
|
|
|
|
database.Factory.ApplicationDeveloper = "Sebastian Esser";
|
|
|
|
|
// turn owner history off
|
|
|
|
|
database.Factory.Options.GenerateOwnerHistory = false;
|
2020-09-14 23:23:17 +03:00
|
|
|
|
|
|
|
|
|
// basic setup
|
|
|
|
|
var site = new IfcSite(database, "SiteA");
|
|
|
|
|
var project = new IfcProject(
|
|
|
|
|
site,
|
|
|
|
|
"SampleProject with a span annotation",
|
|
|
|
|
IfcUnitAssignment.Length.Metre
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// create an annotation
|
2020-12-02 20:59:14 +03:00
|
|
|
|
var annotation = new IfcAnnotation(database)
|
2020-09-14 23:23:17 +03:00
|
|
|
|
{
|
|
|
|
|
Name = "DesignSpeed",
|
|
|
|
|
};
|
2020-12-02 20:59:14 +03:00
|
|
|
|
annotation.AddComment("Annotation item span-placed along the alignment");
|
2020-12-08 10:58:20 +03:00
|
|
|
|
|
2020-12-02 20:59:14 +03:00
|
|
|
|
// link annotation with site
|
|
|
|
|
var contained = new IfcRelContainedInSpatialStructure(site);
|
|
|
|
|
contained.RelatedElements.Add(annotation);
|
2020-09-14 23:23:17 +03:00
|
|
|
|
|
2020-12-02 20:59:14 +03:00
|
|
|
|
#region Alignment
|
|
|
|
|
|
|
|
|
|
var alignment = new IfcAlignment(site)
|
2020-09-14 23:34:53 +03:00
|
|
|
|
{
|
2020-12-02 20:59:14 +03:00
|
|
|
|
Name = "Basic alignment with a single horizontal segment"
|
2020-09-14 23:34:53 +03:00
|
|
|
|
};
|
2020-12-02 20:59:14 +03:00
|
|
|
|
alignment.AddComment("Generate alignment representation");
|
2020-12-08 10:58:20 +03:00
|
|
|
|
|
2020-12-02 20:59:14 +03:00
|
|
|
|
// semantic
|
|
|
|
|
var horizSegment = new IfcAlignmentHorizontalSegment(
|
|
|
|
|
new IfcCartesianPoint(database, 5, 10),
|
|
|
|
|
0,
|
2020-12-08 10:58:20 +03:00
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
200,
|
|
|
|
|
IfcAlignmentHorizontalSegmentTypeEnum.LINE);
|
2020-12-02 20:59:14 +03:00
|
|
|
|
|
2020-12-08 10:58:20 +03:00
|
|
|
|
// geometric representation of a single segment. It gets referenced by IfcCompositeCurve.segments and IfcAlignmentSegment.Representation
|
2020-12-02 20:59:14 +03:00
|
|
|
|
var curveSegment = new IfcCurveSegment(
|
2020-12-08 10:58:20 +03:00
|
|
|
|
IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
|
|
|
|
|
new IfcAxis2Placement2D(new IfcCartesianPoint(database, 0, 0)),
|
|
|
|
|
new IfcParameterValue(0),
|
|
|
|
|
new IfcParameterValue(200),
|
|
|
|
|
null);
|
2020-12-02 20:59:14 +03:00
|
|
|
|
|
2020-12-08 10:25:46 +03:00
|
|
|
|
|
2020-12-08 10:58:20 +03:00
|
|
|
|
var segments = new List<IfcSegment> { curveSegment };
|
2020-12-02 20:59:14 +03:00
|
|
|
|
var compositeCurve = new IfcCompositeCurve(segments);
|
|
|
|
|
|
2020-12-04 11:00:41 +03:00
|
|
|
|
var rep = new IfcShapeRepresentation(compositeCurve)
|
|
|
|
|
{
|
2020-12-08 10:58:20 +03:00
|
|
|
|
RepresentationIdentifier = "Axis",
|
2020-12-08 10:10:29 +03:00
|
|
|
|
RepresentationType = "Curve2D"
|
2020-12-04 11:00:41 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
alignment.Representation = new IfcProductDefinitionShape(rep);
|
2020-12-02 20:59:14 +03:00
|
|
|
|
alignment.Axis = compositeCurve;
|
|
|
|
|
|
2020-12-08 10:58:20 +03:00
|
|
|
|
// create an alignment horizontal instance that takes a list of horizontal segments
|
2020-12-08 10:25:46 +03:00
|
|
|
|
var alignmentHorizontal = new IfcAlignmentHorizontal(database)
|
|
|
|
|
{
|
2020-12-08 10:58:20 +03:00
|
|
|
|
Segments = new LIST<IfcAlignmentHorizontalSegment>() { horizSegment }
|
|
|
|
|
};
|
2020-12-08 10:25:46 +03:00
|
|
|
|
|
2020-12-08 10:58:20 +03:00
|
|
|
|
// link alignment and and its horizontal part semantically
|
|
|
|
|
new IfcRelAggregates(alignment, alignmentHorizontal);
|
2020-12-02 20:59:14 +03:00
|
|
|
|
|
2020-12-08 10:58:20 +03:00
|
|
|
|
// create a new alignmentSegment with then gets one curve segment as its geometric representation
|
2020-12-02 20:59:14 +03:00
|
|
|
|
var alignmentSegment = new IfcAlignmentSegment(database);
|
2020-12-08 10:58:20 +03:00
|
|
|
|
|
|
|
|
|
// link horizontal alignment with the recently created alignment segment
|
2020-12-02 20:59:14 +03:00
|
|
|
|
new IfcRelNests(alignmentHorizontal, alignmentSegment); // sorted list -> IfcRelNests
|
2020-12-08 10:58:20 +03:00
|
|
|
|
|
|
|
|
|
// connect geom representation to this segment
|
|
|
|
|
alignmentSegment.Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(curveSegment));
|
2020-12-02 20:59:14 +03:00
|
|
|
|
|
2020-12-08 10:58:20 +03:00
|
|
|
|
#endregion Alignment
|
2020-12-02 20:59:14 +03:00
|
|
|
|
|
|
|
|
|
#region Annotation placement
|
|
|
|
|
|
|
|
|
|
alignmentSegment.AddComment("Create placement for annotation");
|
|
|
|
|
|
|
|
|
|
var axis2place = new IfcAxis2PlacementLinear(
|
2020-12-08 10:58:20 +03:00
|
|
|
|
new IfcPointByDistanceExpression(25, compositeCurve),
|
|
|
|
|
null,
|
2020-12-02 20:59:14 +03:00
|
|
|
|
null);
|
2020-09-14 23:34:53 +03:00
|
|
|
|
|
2020-12-02 20:59:14 +03:00
|
|
|
|
var linPlacement = new IfcLinearPlacement(axis2place);
|
|
|
|
|
linPlacement.Distance = new IfcPointByDistanceExpression(128, compositeCurve);
|
|
|
|
|
annotation.ObjectPlacement = linPlacement;
|
|
|
|
|
|
2020-12-08 10:58:20 +03:00
|
|
|
|
#endregion Annotation placement
|
2020-12-02 20:59:14 +03:00
|
|
|
|
|
|
|
|
|
#region PSet
|
2020-12-08 10:58:20 +03:00
|
|
|
|
|
2020-12-02 20:59:14 +03:00
|
|
|
|
//var lengthUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.NONE, IfcSIUnitName.METRE);
|
|
|
|
|
|
|
|
|
|
var lengthDerivedUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.KILO, IfcSIUnitName.METRE);
|
|
|
|
|
lengthDerivedUnit.AddComment("PSet setup");
|
|
|
|
|
var timeBaseUnit = new IfcSIUnit(database, IfcUnitEnum.TIMEUNIT, IfcSIPrefix.NONE, IfcSIUnitName.SECOND);
|
|
|
|
|
var timeDerivedUnit = new IfcConversionBasedUnit(IfcUnitEnum.TIMEUNIT, "hour", new IfcMeasureWithUnit(new IfcPositiveInteger(3600), timeBaseUnit));
|
|
|
|
|
|
|
|
|
|
var ifcderivedunitelem1 = new IfcDerivedUnitElement(lengthDerivedUnit, 1);
|
|
|
|
|
var ifcderivedunitelem2 = new IfcDerivedUnitElement(timeDerivedUnit, -1);
|
|
|
|
|
var speedUnit = new IfcDerivedUnit(
|
2020-12-08 10:58:20 +03:00
|
|
|
|
new List<IfcDerivedUnitElement> { ifcderivedunitelem1, ifcderivedunitelem2 },
|
|
|
|
|
IfcDerivedUnitEnum.LINEARVELOCITYUNIT);
|
2020-12-02 20:59:14 +03:00
|
|
|
|
|
2020-09-14 23:23:17 +03:00
|
|
|
|
var pSet = new IfcPropertySet(annotation, "PSET_SpeedData", new List<IfcProperty>
|
|
|
|
|
{
|
2020-12-02 20:59:14 +03:00
|
|
|
|
new IfcPropertySingleValue(database, "CargoSpeed", new IfcLinearVelocityMeasure(60), speedUnit),
|
|
|
|
|
new IfcPropertySingleValue(database, "DesignSpeed", new IfcLinearVelocityMeasure(110), speedUnit)
|
2020-09-14 23:23:17 +03:00
|
|
|
|
});
|
2020-12-08 10:58:20 +03:00
|
|
|
|
|
|
|
|
|
#endregion PSet
|
|
|
|
|
|
2020-09-14 23:23:17 +03:00
|
|
|
|
database.WriteFile("AlignmentWithSpanAnnotation.ifc");
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-08 10:58:20 +03:00
|
|
|
|
}
|