/// <summary> /// Creates the IfcSite item /// </summary> /// <param name="model">XBIM model container, not in transaction</param> /// <param name="siteName">Site Name</param> /// <returns></returns> public void CreateIfcSite(ref IfcStore model, string siteName) { Console.WriteLine("Create IfcSite ..."); using (var txn = model.BeginTransaction("Add IfcSite Item")) { // create an IfcSite instance var ifcSite = model.Instances.New <IfcSite>(); ifcSite.Description = "SiteDescription"; ifcSite.Name = siteName ?? "unknown"; ifcSite.RefElevation = 0.00; Console.WriteLine("Build rel between project and Site..."); // append ifcSite to the overall project instance var myProject = model.Instances.OfType <IfcProject>().FirstOrDefault(); var spatial2Site = model.Instances.New <IfcRelAggregates>(); spatial2Site.RelatingObject = myProject; spatial2Site.RelatedObjects.Add(ifcSite); // the following instances are already in the created project! var ifcAxis2Placement3D = model.Instances.OfType <IfcLocalPlacement>().FirstOrDefault(); // place site at 000 ifcSite.ObjectPlacement = ifcAxis2Placement3D; // Coordinate Reference System txn.Commit(); } }
public static void enrichModelWithIfcEntityLabel(IfcStore ifcStore) { var allObjects = ifcStore.Instances.OfType <IfcObject>(); using (var txn = ifcStore.BeginTransaction("IfcObject Modification Ifc2x3")) { var i = 0; foreach (var ifcObject in allObjects) { if (string.IsNullOrEmpty(ifcObject.Name)) { ifcObject.Name = "Unknown" + (++i); } var entityLabel = ifcObject.EntityLabel; var pSetRel = ifcStore.Instances.New <IfcRelDefinesByProperties>(r => { r.RelatingPropertyDefinition = ifcStore.Instances.New <IfcPropertySet>(pSet => { pSet.Name = "Pset_LibalCommon"; pSet.HasProperties.Add(ifcStore.Instances.New <IfcPropertySingleValue>(p => { p.Name = "IfcEntityLabel"; p.NominalValue = new IfcText("" + entityLabel); })); }); }); pSetRel.RelatedObjects.Add(ifcObject); } txn.Commit(); } }
private static void PopulatePerson(IfcStore model) { using (var txn = model.BeginTransaction("make a person")) { var person = model.DefaultOwningUser.ThePerson; var telecomAddress = model.Instances.New <IfcTelecomAddress>(); var postalAddress = model.Instances.New <IfcPostalAddress>(); person.FamilyName = "doe"; person.GivenName = "john"; person.MiddleNames.Add("simple"); telecomAddress.ElectronicMailAddresses.Add("*****@*****.**"); telecomAddress.TelephoneNumbers.Add("555-1234"); telecomAddress.FacsimileNumbers.Add("555-4321"); telecomAddress.PagerNumber = "who has a pager anymore"; telecomAddress.WWWHomePageURL = "www.google.com"; postalAddress.AddressLines.Add("10 nowhere ave"); postalAddress.AddressLines.Add("nowhereville"); postalAddress.Country = "Antarctica"; postalAddress.Description = "just some dude"; postalAddress.InternalLocation = "Gall Bladder"; postalAddress.PostalBox = "000000"; postalAddress.PostalBox = "1"; postalAddress.Purpose = IfcAddressTypeEnum.OFFICE; postalAddress.Region = "the top one"; postalAddress.Town = "nowhereville"; person.Addresses.Add(telecomAddress); person.Addresses.Add(postalAddress); txn.Commit(); } }
/// <summary> /// Erzeugt Site in Project /// </summary> /// <param name="model"> Projct </param> /// <param name="name"> Bezeichnung der Site </param> /// <param name="placement"> Ursprung </param> /// <param name="refLatitude"> Breitengrad </param> /// <param name="refLongitude"> Längengrad </param> /// <param name="refElevation"> Höhe </param> /// <param name="compositionType"> Bei einer Site nicht ändern </param> /// <returns> </returns> private static IfcSite createSite(IfcStore model, string name, Axis2Placement3D placement = null, double?refLatitude = null, double?refLongitude = null, double?refElevation = null, IfcElementCompositionEnum compositionType = IfcElementCompositionEnum.ELEMENT) { using (var txn = model.BeginTransaction("Create Site")) { var site = model.Instances.New <IfcSite>(s => { s.Name = name; s.CompositionType = compositionType; if (refLatitude.HasValue) { s.RefLatitude = IfcCompoundPlaneAngleMeasure.FromDouble(refLatitude.Value); } if (refLongitude.HasValue) { s.RefLongitude = IfcCompoundPlaneAngleMeasure.FromDouble(refLongitude.Value); } s.RefElevation = refElevation; placement = placement ?? Axis2Placement3D.Standard; s.ObjectPlacement = createLocalPlacement(model, placement); }); txn.Commit(); return(site); } }
static private IfcSpace CreateSpace(IfcStore model, double length, double width, double height) { // //begin a transaction using (var txn = model.BeginTransaction("Create Space")) { var space = model.Instances.New <IfcSpace>(); space.Name = "Space"; //represent wall as a rectangular profile var rectProf = model.Instances.New <IfcRectangleProfileDef>(); rectProf.ProfileType = (Xbim.Ifc2x3.ProfileResource.IfcProfileTypeEnum)IfcProfileTypeEnum.AREA; rectProf.XDim = width; rectProf.YDim = length; var insertPoint = model.Instances.New <IfcCartesianPoint>(); insertPoint.SetXY(0, 400); //insert at arbitrary position rectProf.Position = model.Instances.New <IfcAxis2Placement2D>(); rectProf.Position.Location = insertPoint; //model as a swept area solid var body = model.Instances.New <IfcExtrudedAreaSolid>(); body.Depth = height; body.SweptArea = rectProf; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); //parameters to insert the geometry in the model var origin = model.Instances.New <IfcCartesianPoint>(); origin.SetXYZ(0, 0, 0); body.Position = model.Instances.New <IfcAxis2Placement3D>(); body.Position.Location = origin; //Create a Definition shape to hold the geometry var shape = model.Instances.New <IfcShapeRepresentation>(); var modelContext = model.Instances.OfType <IfcGeometricRepresentationContext>().FirstOrDefault(); shape.ContextOfItems = modelContext; shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add(body); //Create a Product Definition and add the model geometry to the wall var rep = model.Instances.New <IfcProductDefinitionShape>(); rep.Representations.Add(shape); space.Representation = rep; //now place the wall into the model var lp = model.Instances.New <IfcLocalPlacement>(); var ax3D = model.Instances.New <IfcAxis2Placement3D>(); ax3D.Location = origin; ax3D.RefDirection = model.Instances.New <IfcDirection>(); ax3D.RefDirection.SetXYZ(0, 1, 0); ax3D.Axis = model.Instances.New <IfcDirection>(); ax3D.Axis.SetXYZ(0, 0, 1); lp.RelativePlacement = ax3D; space.ObjectPlacement = lp; return(space); } }
static private IfcStore ProcessModels(XBimFederation xFedModel) { IfcStore fedModel = IfcStore.Create(null, IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel); using (var txn = fedModel.BeginTransaction()) { var project = fedModel.Instances.New <Xbim.Ifc4.Kernel.IfcProject>(); //project.Name = "Default Project Name"; project.Name = xFedModel.FederationName; project.LongName = xFedModel.FederationName + " - Federation"; project.Description = xFedModel.FederationDescription; project.Initialize(ProjectUnits.SIUnitsUK); txn.Commit(); } var informUser = true; for (var i = 0; i < xFedModel.GetMemberModelList().Count; i++) { var fileName = xFedModel.GetMemberModelList()[i].ModelFileName; if (!addReferencedModel(fileName, fedModel, i, informUser, out informUser)) { break; // The process is being cancelled by user } } return(fedModel); }
private void Init(IfcStore m) { using (var txn = m.BeginTransaction("Initialise WCS")) { var context3D = m.Instances.OfType <IfcGeometricRepresentationContext>() .Where(c => c.CoordinateSpaceDimension == 3) .FirstOrDefault(); if (context3D.WorldCoordinateSystem is IfcAxis2Placement3D wcs) { WCS = wcs; Origin3D = wcs.Location; AxisZ3D = toolkit_factory.MakeDirection(m, 0, 0, 1); wcs.Axis = AxisZ3D; AxisX3D = toolkit_factory.MakeDirection(m, 1, 0, 0); wcs.RefDirection = AxisX3D; AxisY3D = toolkit_factory.MakeDirection(m, 0, 1, 0); } var context2D = m.Instances.OfType <IfcGeometricRepresentationContext>() .Where(c => c.CoordinateSpaceDimension == 2) .FirstOrDefault(); if (context2D.WorldCoordinateSystem is IfcAxis2Placement2D wcs2d) { WCS2D = wcs2d; Origin2D = wcs2d.Location; AxisX2D = toolkit_factory.MakeDirection(m, 1, 0); wcs2d.RefDirection = AxisX2D; AxisY2D = toolkit_factory.MakeDirection(m, 0, 1, 0); } txn.Commit(); } }
/// <summary> /// Add some properties to the wall, /// </summary> /// <param name="model">XbimModel</param> /// <param name="wall"></param> private void AddPropertiesToWall(IfcStore model, IfcWallStandardCase wall) { using (var txn = model.BeginTransaction("Create Wall")) { CreateSimpleProperty(model, wall); txn.Commit(); } }
public static void AddPrductIntoSpatial(IfcStore m, IfcSpatialStructureElement spatial, IfcProduct p, string txt) { using (var txn = m.BeginTransaction(txt)) { spatial.AddElement(p); txn.Commit(); } }
private static IfcShellBasedSurfaceModel createShellBasedSurfaceModel(IfcStore model, Vector3 origin, Mesh mesh, out RepresentationType representationType, out RepresentationIdentifier representationIdentifier) { //Serilog.Log.Logger = new LoggerConfiguration() // .MinimumLevel.Debug() // .WriteTo.File(System.Configuration.ConfigurationManager.AppSettings["LogFilePath"]) // .CreateLogger(); if (mesh.MaxFaceCorners < 3) { //Log.Error("Creation of IfcShellBasedSurfaceModel unsuccessful. Mesh has no Faces"); throw new Exception("Mesh has no Faces"); } using (var txn = model.BeginTransaction("Create Mesh")) { var vmap = new Dictionary <int, int>(); var cpl = new List <IfcCartesianPoint>(); for (int i = 0, j = 0; i < mesh.Points.Count; i++) { if (mesh.VertexEdges[i] < 0) { continue; } vmap.Add(i, j); var pt = mesh.Points[i]; cpl.Add(model.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(pt.X - origin.X, pt.Y - origin.Y, pt.Z - origin.Z))); j++; } var sbsm = model.Instances.New <IfcShellBasedSurfaceModel>(s => s.SbsmBoundary.Add(model.Instances.New <IfcOpenShell>(o => o.CfsFaces .AddRange(mesh.FaceEdges.Select(fe => model.Instances.New <IfcFace>(x => x.Bounds .Add(model.Instances.New <IfcFaceOuterBound>(b => { b.Bound = model.Instances.New <IfcPolyLoop>(p => { int curr = fe; do { p.Polygon.Add(cpl[vmap[mesh.EdgeVertices[curr]]]); curr = mesh.EdgeNexts[curr]; } while(curr != fe && p.Polygon.Count < mesh.MaxFaceCorners); }); b.Orientation = true; })))))))); txn.Commit(); representationIdentifier = RepresentationIdentifier.Body; representationType = RepresentationType.SurfaceModel; //Log.Information("IfcShellBasedSurfaceModel created"); return(sbsm); } }
public static void CreateTriangulatedFaceSet(IfcStore model) { // only available in IFC4 if (((IModel)model).SchemaVersion != XbimSchemaVersion.Ifc4) { return; } using (var txn = model.BeginTransaction("IfcTriangulatedFaceSet")) { var coordinates = model.Instances.New <IfcCartesianPointList3D>(); var mesh = model.Instances.New <IfcTriangulatedFaceSet>(fs => { fs.Closed = false; fs.Coordinates = coordinates; }); var points = new double[][] { new [] { 0d, 0d, 0d }, new [] { 1d, 0d, 0d }, new [] { 1d, 1d, 0d }, new [] { 0d, 1d, 0d }, new [] { 0d, 0d, 2d }, new [] { 1d, 0d, 2d }, new [] { 1d, 1d, 2d }, new [] { 0d, 1d, 2d } }; var indices = new long[][] { new [] { 1L, 6L, 5L }, new [] { 1L, 2L, 6L }, new [] { 6L, 2L, 7L }, new [] { 7L, 2L, 3L }, new [] { 7L, 8L, 6L }, new [] { 6L, 8L, 5L }, new [] { 5L, 8L, 1L }, new [] { 1L, 8L, 4L }, new [] { 4L, 2L, 1L }, new [] { 2L, 4L, 3L }, new [] { 4L, 8L, 7L }, new [] { 7L, 3L, 4L } }; for (int i = 0; i < points.Length; i++) { var values = points[i].Select(v => new IfcLengthMeasure(v)); coordinates.CoordList.GetAt(i).AddRange(values); } for (int i = 0; i < indices.Length; i++) { var values = indices[i].Select(v => new IfcPositiveInteger(v)); mesh.CoordIndex.GetAt(i).AddRange(values); } txn.Commit(); } }
public override List <IfcBuildingElement> ToBuildingElementIfc(IfcStore model) { using (var transaction = model.BeginTransaction("Create Profile Element")) { var material = model.Instances.New <IfcMaterial>(); material.Category = Material.Name; material.Name = Material.Grade; var ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>(); ifcRelAssociatesMaterial.RelatingMaterial = material; var ifcCartesianPoints = IfcTools.PointsToIfcCartesianPoints(model, Profile.ProfilePoints, true); var polyline = model.Instances.New <IfcPolyline>(); polyline.Points.AddRange(ifcCartesianPoints); var profile = model.Instances.New <IfcArbitraryClosedProfileDef>(); profile.OuterCurve = polyline; profile.ProfileName = Profile.Name; profile.ProfileType = IfcProfileTypeEnum.AREA; List <IfcShapeRepresentation> shapes = new List <IfcShapeRepresentation>(); foreach (var t in ElementLines) { var body = model.Instances.New <IfcExtrudedAreaSolid>(); body.Depth = t.Length; body.SweptArea = profile; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); var origin = model.Instances.New <IfcCartesianPoint>(); origin.SetXYZ(0, 0, 0); body.Position = model.Instances.New <IfcAxis2Placement3D>(); body.Position.Location = origin; var shape = model.Instances.New <IfcShapeRepresentation>(); var modelContext = model.Instances.OfType <IfcGeometricRepresentationContext>().FirstOrDefault(); shape.ContextOfItems = modelContext; shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add(body); shapes.Add(shape); } var buildingElements = IfcTools.CreateBuildingElements(model, ElementType, Name, shapes, SectionInsertPlanes, ifcRelAssociatesMaterial); transaction.Commit(); return(buildingElements); } }
private IfcSlab CreateIfcLanding(IfcStore model, LinearPath landingPline, double landingThickness) { //begin a transaction using (var trans = model.BeginTransaction("Create Wall")) { IfcSlab landing = model.Instances.New <IfcSlab>(); IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); //Create a Definition shape to hold the geometry of the Stair 3D body IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (landingPline.Vertices /*.Select(v => v * 1000)*/).ToList()); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, landingThickness, stepProfile, extrusionDir); body.BodyPlacementSet(model, 0, 0, 0); shape.Items.Add(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>(); prDefShape.Representations.Add(shape); landing.Representation = prDefShape; //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(0, 0, 0); //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(1, 0, 0); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the slab into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); landing.ObjectPlacement = lp; trans.Commit(); return(landing); } }
/// <summary> /// Wraps an IfcStore modification into a transaction context. /// </summary> /// <param name="action">The modification return true, if transaction shall be applied</param> public void Wrap(Func <IfcStore, bool> action) { using (var txn = Store.BeginTransaction(TransactionContext)) { try { if (action(Store)) { txn.Commit(); } else { txn.RollBack(); Log?.LogWarning($"Detected cancellation of commit '{txn.Name}'"); } } catch (Exception e) { txn.RollBack(); Log?.LogError(e, "Exception caught. Rollback done."); } } }
public void Delete <T>() where T : IPersistEntity { using (var txn = IfcStore.BeginTransaction("Deleting")) { var columns = IfcStore.Instances.OfType <T>(); int c = columns.Count(); for (int i = 0; i < c; i++) { IfcStore.Delete(columns.FirstOrDefault()); } txn.Commit(); } }
protected static IfcStore CreateandInitModel(string projectName = null) { IfcStore model = IfcStore.Create(new XbimEditorCredentials() { ApplicationFullName = "V6", ApplicationDevelopersName = "SoftTech", ApplicationIdentifier = "v6", ApplicationVersion = "0.1", EditorsFamilyName = "Bloggs", EditorsGivenName = "Joe", EditorsOrganisationName = "SoftTech" }, Xbim.Common.Step21.IfcSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel); //create an empty model //Begin a transaction as all changes to a model are transacted using (var txn = model.BeginTransaction("Initialise Model")) { //do once only initialisation of model application and editor values model.DefaultOwningUser.ThePerson.GivenName = "n/a"; model.DefaultOwningUser.ThePerson.FamilyName = "n/a"; model.DefaultOwningUser.TheOrganization.Name = "n/a"; model.DefaultOwningApplication.ApplicationIdentifier = "SoftTech"; model.DefaultOwningApplication.ApplicationDeveloper.Name = "SoftTech Ltd."; model.DefaultOwningApplication.ApplicationFullName = "V6"; model.DefaultOwningApplication.Version = "n/a"; //set up a project and initialise the defaults var project = model.Instances.New <IfcProject>(); //project.Initialize(Xbim.Common.ProjectUnits.SIUnitsUK); //project.SetOrChangeSiUnit(Xbim.Ifc2x3.MeasureResource.IfcUnitEnum.LENGTHUNIT // , Xbim.Ifc2x3.MeasureResource.IfcSIUnitName.METRE, // null); project.Initialize(Xbim.Common.ProjectUnits.SIUnitsUK); project.SetOrChangeConversionUnit(Xbim.Ifc2x3.MeasureResource.IfcUnitEnum.LENGTHUNIT, Xbim.Ifc2x3.MeasureResource.ConversionBasedUnit.Inch); project.Name = "testProject"; project.OwnerHistory.OwningUser = model.DefaultOwningUser as IfcPersonAndOrganization; project.OwnerHistory.OwningApplication = model.DefaultOwningApplication as IfcApplication; //project.ModelContext.WorldCoordinateSystem = model._New<IfcAxis2Placement3D>(c => // { // c.Axis = model._New<IfcDirection>(d => d.SetXYZ(0,0, -1)); // c.RefDirection = model._New<IfcDirection>(d => d.SetXYZ(0, 1, 0)); // } // ); txn.Commit(); return(model); } }
/// Achtung mesh muss zwingend aus Dreiecken Bestehen private static IfcTriangulatedFaceSet createTriangulatedFaceSet(IfcStore model, Vector3 origin, Mesh mesh, out RepresentationType representationType, out RepresentationIdentifier representationIdentifier) { if (mesh.MaxFaceCorners != 3 || mesh.MinFaceCorners != 3) { throw new Exception("Mesh is not Triangular"); } using (var txn = model.BeginTransaction("Create TIN")) { var vmap = new Dictionary <int, int>(); var cpl = model.Instances.New <IfcCartesianPointList3D>(c => { for (int i = 0, j = 0; i < mesh.Points.Count; i++) { if (mesh.VertexEdges[i] < 0) { continue; } vmap.Add(i, j + 1); var pt = mesh.Points[i]; var coo = c.CoordList.GetAt(j++); coo.Add(pt.X - origin.X); coo.Add(pt.Y - origin.Y); coo.Add(pt.Z - origin.Z); } }); var tfs = model.Instances.New <IfcTriangulatedFaceSet>(t => { t.Closed = false; // nur bei Volumenkörpern t.Coordinates = cpl; int cnt = 0; foreach (int fe in mesh.FaceEdges) { var fi = t.CoordIndex.GetAt(cnt++); fi.Add(vmap[mesh.EdgeVertices[fe]]); fi.Add(vmap[mesh.EdgeVertices[mesh.EdgeNexts[fe]]]); fi.Add(vmap[mesh.EdgeVertices[mesh.EdgeNexts[mesh.EdgeNexts[fe]]]]); } }); txn.Commit(); representationIdentifier = RepresentationIdentifier.Body; representationType = RepresentationType.Tessellation; return(tfs); } }
public static IfcSite CreateSite(IfcStore m, string name) { using (var txn = m.BeginTransaction("Create Site")) { var site = m.Instances.New <IfcSite>(s => { s.Name = name; s.CompositionType = IfcElementCompositionEnum.ELEMENT; }); var project = m.Instances.OfType <IfcProject>().FirstOrDefault(); project.AddSite(site); txn.Commit(); return(site); } }
public void CommitAll(IfcStore model) { if (model.CurrentTransaction == null) { using (var txn = model.BeginTransaction("Commit All")) { DoCommitAll(model); txn.Commit(); } } else { DoCommitAll(model); } }
private static IfcShellBasedSurfaceModel createShellBasedSurfaceModelViaTin(IfcStore model, Vector3 origin, Tin tin, out RepresentationType representationType, out RepresentationIdentifier representationIdentifier) { /* Validierung -> bereits bei Reader implementieren? * if (mesh.MaxFaceCorners < 3) * { throw new Exception("Mesh has no Faces"); } */ //init Logger Logger logger = LogManager.GetCurrentClassLogger(); using (var txn = model.BeginTransaction("Create Tin")) { var vmap = new Dictionary <int, int>(); var cpl = new List <IfcCartesianPoint>(); for (int i = 0, j = 0; i < tin.Points.Count; i++) { vmap.Add(i, j); var pt = tin.Points[i]; cpl.Add(model.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(pt.X - origin.X, pt.Y - origin.Y, pt.Z - origin.Z))); j++; } var sbsm = model.Instances.New <IfcShellBasedSurfaceModel>(s => s.SbsmBoundary.Add(model.Instances.New <IfcOpenShell>(o => o.CfsFaces .AddRange(tin.TriangleVertexPointIndizes().Select(tri => model.Instances.New <IfcFace>(x => x.Bounds .Add(model.Instances.New <IfcFaceOuterBound>(b => { b.Bound = model.Instances.New <IfcPolyLoop>(p => { p.Polygon.Add(cpl[vmap[tri[0]]]); p.Polygon.Add(cpl[vmap[tri[1]]]); p.Polygon.Add(cpl[vmap[tri[2]]]); }); b.Orientation = true; })))))))); //logger.Debug("Processed: " + ); txn.Commit(); representationIdentifier = RepresentationIdentifier.Body; representationType = RepresentationType.SurfaceModel; //TRASHLÖSUNG below: long numTri = ((sbsm.Model.Instances.Count - vmap.Count) / 3) - 10; logger.Debug("Processed: " + vmap.Count + " points; " + numTri + " triangels)"); return(sbsm); } }
private IfcAlignment CreateStraightAlignment(IfcStore m, string txt) { const int LENGTH = 80000; //the total length of horizontal lineSeq 2D const double DIRECTION = Math.PI / 6; //the direction of horizontal lineSeq const int DISTANCE = 0; //the start length of verticalSeq along horizontal line const int LENGTH2 = 60000; //the end along horizontal const int HEIGHT = 15000; //the height of verticalSeq const double GRADIENT = 0.0; //gradient of start in verticalSeq using (var txn = m.BeginTransaction("Create straight Alignment")) { var alignCurve = m.Instances.New <IfcAlignmentCurve>(ac => { var lineSeg = m.Instances.New <IfcAlignment2DHorizontalSegment>(s => { s.CurveGeometry = toolkit_factory.MakeLineSegment2D(m, Origin2D, DIRECTION, LENGTH); s.TangentialContinuity = true; }); ac.Horizontal = m.Instances.New <IfcAlignment2DHorizontal>(h => h.Segments.Add(lineSeg)); var versegLine = m.Instances.New <IfcAlignment2DVerSegLine>(sl => { sl.StartDistAlong = DISTANCE; sl.HorizontalLength = LENGTH2; sl.StartHeight = HEIGHT; sl.StartGradient = GRADIENT; sl.TangentialContinuity = true; }); ac.Vertical = m.Instances.New <IfcAlignment2DVertical>(v => v.Segments.Add(versegLine)); ac.Tag = "Road alignment curve"; }); var alignment = m.Instances.New <IfcAlignment>(a => { a.Name = txt; a.Axis = alignCurve; a.ObjectPlacement = m.Instances.New <IfcLocalPlacement>(p => p.RelativePlacement = WCS); var sweepCurveSolid = toolkit_factory.CreateSolidShapeBaseOnCurve(m, alignCurve, 0, LENGTH); toolkit_factory.SetSurfaceColor(m, sweepCurveSolid, 1, 0, 0); var bodyshape = toolkit_factory.MakeShapeRepresentation(m, 3, "Body", "AdvancedSweptSolid", sweepCurveSolid); a.Representation = m.Instances.New <IfcProductDefinitionShape>(pd => { pd.Representations.Add(bodyshape); }); }); txn.Commit(); return(alignment); } }
public override void Calculate() { if (InputPorts[0].Data == null) { return; } var modelInfo = InputPorts[0].Data as ModelInfo; if (modelInfo == null) { return; } var model = modelController.GetModel(modelInfo.modelId) as IfcModel; if (model == null) { return; } // Get the model content xModel = model.GetModel(); context = model.xModelContext; _elements = model.GetAllElements(); // Write a Property for each element var propertySet = _control.PropertySetTextBox.Text; var property = _control.PropertyTextBox.Text; // foreach (var item in _elements) // { // (item as IfcProduct).PropertySets.FirstOrDefault(). // } foreach (var element in _elements) { using (var txn = xModel.BeginTransaction("Add some Properties Wall")) { CreateSimpleProperty(xModel, element); txn.Commit(); } } }
public static IfcSite CreateSite(IfcStore model, string name, double x = 0, double y = 0, double z = 0) { using (var txn = model.BeginTransaction("Create Site")) { var site = model.Instances.New <IfcSite>(); site.Name = name; site.OwnerHistory.OwningUser = model.DefaultOwningUser as Xbim.Ifc2x3.ActorResource.IfcPersonAndOrganization; site.OwnerHistory.OwningApplication = model.DefaultOwningApplication as Xbim.Ifc2x3.UtilityResource.IfcApplication; //building.ElevationOfRefHeight = elevHeight; site.CompositionType = IfcElementCompositionEnum.ELEMENT; IfcProject(model).AddSite(site); txn.Commit(); return(site); } }
public override List <IfcBuildingElement> ToBuildingElementIfc(IfcStore model) { using (var transaction = model.BeginTransaction("Create Mesh Element")) { MeshFaceList faces = Mesh.Faces; MeshVertexList vertices = Mesh.Vertices; List <IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices); IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices); var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh"); shape.Items.Add(faceBasedSurfaceModel); var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade); var buildingElements = IfcTools.CreateBuildingElements(model, ElementType, Name, shape, InsertPlanes, ifcRelAssociatesMaterial); transaction.Commit(); return(buildingElements); } }
internal static IfcBuildingStorey CreateStorey(IfcStore model, IfcBuilding building, string BlkName, int storeyNumber, FloorBase cadFloor) { IfcBuildingStorey storey; using (var trans = model.BeginTransaction("Add Storey")) { storey = model.Instances.New <IfcBuildingStorey>(); storey.Name = BlkName + $"F{storeyNumber}"; IfcRelAggregates rel = model.Instances.New <IfcRelAggregates>(); rel.RelatingObject = building; rel.RelatedObjects.Add(storey); XbimCreateBuilding.AddStoreyProperties(model, storey, cadFloor.Height, cadFloor.Level); trans.Commit(); } return(storey); }
private static IfcShapeRepresentation createShapeRepresentation(IfcStore model, IfcGeometricRepresentationItem item, RepresentationIdentifier identifier, RepresentationType type) { // //begin a transaction using (var txn = model.BeginTransaction("Create Shaperepresentation")) { //Create a Definition shape to hold the geometry var shape = model.Instances.New <IfcShapeRepresentation>(s => { s.ContextOfItems = model.Instances.OfType <IfcGeometricRepresentationContext>().FirstOrDefault(); s.RepresentationType = type.ToString(); s.RepresentationIdentifier = identifier.ToString(); s.Items.Add(item); }); txn.Commit(); return(shape); } }
private void CreateProject(IfcStore model, BaseUnits units = BaseUnits.Meters) { using (var txn = model.BeginTransaction("Initialising...")) { var project = model.Instances.New <IfcProject>(); project.Initialize(ProjectUnits.SIUnitsUK); project.Name = "Pegasus"; // By default the units are mm, m2 and m3 // Change the length unit to meters (metres) // Note xbim doesn't have imperial units so we might have to add a complete set of imperial units here, // check out IfcProjectPartial.cs switch (units) { case BaseUnits.Millimeters: model.Instances.OfType <IfcSIUnit>().Where(u => u.UnitType == IfcUnitEnum.LENGTHUNIT).ToList().ForEach(u => u.Prefix = null); break; case BaseUnits.Meters: break; case BaseUnits.Feet: { IfcUnitAssignment unitAssignment = model.Instances.New <IfcUnitAssignment>(); unitAssignment.SetOrChangeConversionUnit(IfcUnitEnum.LENGTHUNIT, ConversionBasedUnit.Foot); unitAssignment.SetOrChangeConversionUnit(IfcUnitEnum.AREAUNIT, ConversionBasedUnit.SquareFoot); unitAssignment.SetOrChangeConversionUnit(IfcUnitEnum.VOLUMEUNIT, ConversionBasedUnit.CubicFoot); } break; case BaseUnits.Inches: { IfcUnitAssignment unitAssignment = model.Instances.New <IfcUnitAssignment>(); unitAssignment.SetOrChangeConversionUnit(IfcUnitEnum.LENGTHUNIT, ConversionBasedUnit.Inch); unitAssignment.SetOrChangeConversionUnit(IfcUnitEnum.AREAUNIT, ConversionBasedUnit.SquareFoot); unitAssignment.SetOrChangeConversionUnit(IfcUnitEnum.VOLUMEUNIT, ConversionBasedUnit.CubicFoot); } break; } txn.Commit(); } }
/// <summary> /// Create BridgePart Entities /// </summary> /// <param name="model"></param> /// <exception cref="Exception"></exception> public void CreateIfcBridgePartEntities(ref IfcStore model) { // other services needed for this method: var placementService = new PlacementService(); using (var txn = model.BeginTransaction("Add Bridge Part structure")) { var superStructure = model.Instances.New <IfcBridgePart>(); superStructure.Name = "Superstructure"; superStructure.ObjectPlacement = placementService.AddLocalPlacement(ref model, 0, 0, 0); superStructure.CompositionType = IfcElementCompositionEnum.ELEMENT; superStructure.PredefinedType = IfcBridgePartTypeEnum.SUPERSTRUCTURE; var subStructure = model.Instances.New <IfcBridgePart>(); subStructure.Name = "Substructure"; subStructure.ObjectPlacement = placementService.AddLocalPlacement(ref model, 0, 0, 0); subStructure.CompositionType = IfcElementCompositionEnum.ELEMENT; subStructure.PredefinedType = IfcBridgePartTypeEnum.SUBSTRUCTURE; var surfaceStructure = model.Instances.New <IfcBridgePart>(); surfaceStructure.Name = "Surfacestructure"; surfaceStructure.ObjectPlacement = placementService.AddLocalPlacement(ref model, 0, 0, 0); surfaceStructure.CompositionType = IfcElementCompositionEnum.ELEMENT; surfaceStructure.PredefinedType = IfcBridgePartTypeEnum.SURFACESTRUCTURE; // grab the existing bridge var myBridge = model.Instances.OfType <IfcBridge>().FirstOrDefault(); if (myBridge == null) { throw new Exception("No IfcBridge Item in the current model. "); } var spatial2Bridge = model.Instances.New <IfcRelAggregates>(); spatial2Bridge.RelatingObject = myBridge; spatial2Bridge.RelatedObjects.Add(superStructure); spatial2Bridge.RelatedObjects.Add(subStructure); spatial2Bridge.RelatedObjects.Add(surfaceStructure); txn.Commit(); } }
/// <summary> /// Create DSMSystem /// </summary> /// <param name="model"></param> /// <param name="name">DSMSystem name</param> /// <returns></returns> private static IfcDSMSystem CreateDSMSystem(IfcStore model, string name) { using (var txn = model.BeginTransaction("Create DSMSystem")) { var system = model.Instances.New <IfcDSMSystem>(); system.Name = name; //get the building there should only be one and it should exist var building = model.Instances.OfType <IfcBuilding>().FirstOrDefault(); if (building != null) { var rs = model.Instances.New <IfcRelServicesBuildings>(); rs.RelatingSystem = system; rs.RelatedBuildings.Add(building); } txn.Commit(); return(system); } }
private static IfcBuilding CreateBuilding(IfcStore model, string name) { using (var txn = model.BeginTransaction("Create Building")) { var building = model.Instances.New <IfcBuilding>(); building.Name = name; building.CompositionType = IfcElementCompositionEnum.ELEMENT; var localPlacement = model.Instances.New <IfcLocalPlacement>(); building.ObjectPlacement = localPlacement; var placement = model.Instances.New <IfcAxis2Placement3D>(); localPlacement.RelativePlacement = placement; placement.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(0, 0, 0)); //get the project there should only be one and it should exist var project = model.Instances.OfType <IfcProject>().FirstOrDefault(); project?.AddBuilding(building); txn.Commit(); return(building); } }