/// <summary> /// Initialisiert ein leeres Projekt /// </summary> private static IfcStore createandInitModel(string projectName, string editorsFamilyName, string editorsGivenName, string editorsOrganisationName, out IfcProject project) { //first we need to set up some credentials for ownership of data in the new model var credentials = new XbimEditorCredentials { ApplicationDevelopersName = "HTW Dresden for DDBIM", ApplicationFullName = System.Reflection.Assembly.GetExecutingAssembly().FullName, ApplicationIdentifier = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, ApplicationVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), EditorsFamilyName = editorsFamilyName, EditorsGivenName = editorsGivenName, EditorsOrganisationName = editorsOrganisationName }; var model = IfcStore.Create(credentials, XbimSchemaVersion.Ifc2X3, XbimStoreType.EsentDatabase); //Begin a transaction as all changes to a model are ACID using (var txn = model.BeginTransaction("Initialise Model")) { //create a project project = model.Instances.New <IfcProject>(); //set the units to SI (metres) project.Initialize(ProjectUnits.SIUnitsUK); project.Name = projectName; project.UnitsInContext.SetOrChangeSiUnit(IfcUnitEnum.LENGTHUNIT, IfcSIUnitName.METRE, null); //now commit the changes, else they will be rolled back at the end of the scope of the using statement txn.Commit(); } return(model); }
private static IfcStore CreateAndInitModel(string projectName) { var credentials = new XbimEditorCredentials { ApplicationDevelopersName = "xbim developer", ApplicationFullName = "T-Rex", ApplicationIdentifier = "T-Rex", ApplicationVersion = "0.2", EditorsFamilyName = "Team", EditorsGivenName = "xbim", EditorsOrganisationName = "xbim developer" }; var model = IfcStore.Create(credentials, XbimSchemaVersion.Ifc4x1, XbimStoreType.InMemoryModel); using (ITransaction transaction = model.BeginTransaction("Initialise Model")) { IfcProject project = model.Instances.New <IfcProject>(); project.Initialize(ProjectUnits.SIUnitsUK); project.Name = projectName; transaction.Commit(); } return(model); }
/// <summary> /// Sets up the basic parameters any model must provide, units, ownership etc /// </summary> /// <param name="projectName">Name of the project</param> /// <returns></returns> private XbimModel CreateandInitModel(string projectName) { XbimModel model = XbimModel.CreateModel(projectName + ".xBIM");; //create an empty model //Begin a transaction as all changes to a model are transacted using (XbimReadWriteTransaction txn = model.BeginTransaction("Initialise Model")) { //do once only initialisation of model application and editor values model.DefaultOwningUser.ThePerson.GivenName = "John"; model.DefaultOwningUser.ThePerson.FamilyName = "Bloggs"; model.DefaultOwningUser.TheOrganization.Name = "Department of Building"; model.DefaultOwningApplication.ApplicationIdentifier = "Construction Software inc."; model.DefaultOwningApplication.ApplicationDeveloper.Name = "Construction Programmers Ltd."; model.DefaultOwningApplication.ApplicationFullName = "Ifc sample programme"; model.DefaultOwningApplication.Version = "2.0.1"; //set up a project and initialise the defaults IfcProject project = model.Instances.New <IfcProject>(); project.Initialize(ProjectUnits.SIUnitsUK); project.Name = "testProject"; project.OwnerHistory.OwningUser = model.DefaultOwningUser; project.OwnerHistory.OwningApplication = model.DefaultOwningApplication; //validate and commit changes if (model.Validate(txn.Modified(), Console.Out) == 0) { txn.Commit(); return(model); } } return(null); //failed so return nothing }
/// <summary> /// SetUp the Model Project Object /// </summary> /// <param name="row">COBieFacilityRow object to read data from</param> private void SetUpProject(COBieFacilityRow row) { IfcProject ifcProject = Model.IfcProject; ifcProject.Initialize(ProjectUnits.SIUnitsUK); SetOwnerHistory(ifcProject, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn); //using statement will set the Model.OwnerHistoryAddObject to ifcProject.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcProject.OwnerHistory)) { if (ValidateString(row.ProjectName)) { ifcProject.Name = row.ProjectName; } if (ValidateString(row.ProjectDescription)) { ifcProject.Description = row.ProjectDescription; } if (ValidateString(row.Phase)) { ifcProject.Phase = row.Phase; } if (ValidateString(row.LinearUnits)) { SetUnitToProject(IfcUnitEnum.LENGTHUNIT, row.LinearUnits); } AddGlobalId(row.ExternalProjectIdentifier, ifcProject); if (ValidateString(row.AreaUnits)) { SetUnitToProject(IfcUnitEnum.AREAUNIT, row.AreaUnits); } if (ValidateString(row.VolumeUnits)) { SetUnitToProject(IfcUnitEnum.VOLUMEUNIT, row.VolumeUnits); } if (ValidateString(row.CurrencyUnit)) { SetMonetaryUnit(row.CurrencyUnit); } } }
private void InitialiseUnits(IfcProject ifcProject) { ifcProject.Initialize(ProjectUnits.SIUnitsUK); //Area var areaUnit = ifcProject.UnitsInContext.AreaUnit as IfcSIUnit; //they always are as we are initialising to this if (areaUnit != null && Exchanger.DefaultAreaUnit.HasValue) { var defaultAreaUnit = Exchanger.DefaultAreaUnit.Value; areaUnit.UnitType = defaultAreaUnit.UnitName; areaUnit.Prefix = defaultAreaUnit.SiPrefix; if (defaultAreaUnit.SiUnitName != null) { areaUnit.Name = defaultAreaUnit.SiUnitName.Value; } if (Math.Abs(defaultAreaUnit.ConversionFactor - 1) > 1e-9) //need to create conversion units { var convBasedUnit = Exchanger.TargetRepository.Instances.New <IfcConversionBasedUnit>(); var measureWithUnit = Exchanger.TargetRepository.Instances.New <IfcMeasureWithUnit>(); var dimensionalUnits = Exchanger.TargetRepository.Instances.New <IfcDimensionalExponents>(); dimensionalUnits.LengthExponent = 2; convBasedUnit.Dimensions = dimensionalUnits; measureWithUnit.ValueComponent = new IfcRatioMeasure(defaultAreaUnit.ConversionFactor); measureWithUnit.UnitComponent = areaUnit; convBasedUnit.ConversionFactor = measureWithUnit; convBasedUnit.UnitType = areaUnit.UnitType; convBasedUnit.Name = defaultAreaUnit.UserDefinedSiUnitName; } } //Length var linearUnit = ifcProject.UnitsInContext.LengthUnit as IfcSIUnit; //they always are as we are initialising to this if (linearUnit != null && Exchanger.DefaultLinearUnit.HasValue) { var defaultLinearUnit = Exchanger.DefaultLinearUnit.Value; linearUnit.UnitType = defaultLinearUnit.UnitName; linearUnit.Prefix = defaultLinearUnit.SiPrefix; if (defaultLinearUnit.SiUnitName != null) { linearUnit.Name = defaultLinearUnit.SiUnitName.Value; } if (Math.Abs(defaultLinearUnit.ConversionFactor - 1) > 1e-9) //need to create conversion units { var convBasedUnit = Exchanger.TargetRepository.Instances.New <IfcConversionBasedUnit>(); var dimensionalUnits = Exchanger.TargetRepository.Instances.New <IfcDimensionalExponents>(); dimensionalUnits.LengthExponent = 1; convBasedUnit.Dimensions = dimensionalUnits; var measureWithUnit = Exchanger.TargetRepository.Instances.New <IfcMeasureWithUnit>(); measureWithUnit.ValueComponent = new IfcRatioMeasure(defaultLinearUnit.ConversionFactor); measureWithUnit.UnitComponent = linearUnit; convBasedUnit.ConversionFactor = measureWithUnit; convBasedUnit.UnitType = linearUnit.UnitType; convBasedUnit.Name = defaultLinearUnit.UserDefinedSiUnitName; } } //Volume var volumeUnit = ifcProject.UnitsInContext.VolumeUnit as IfcSIUnit; //they always are as we are initialising to this if (volumeUnit != null && Exchanger.DefaultVolumeUnit.HasValue) { var defaultVolumeUnit = Exchanger.DefaultVolumeUnit.Value; volumeUnit.UnitType = defaultVolumeUnit.UnitName; volumeUnit.Prefix = defaultVolumeUnit.SiPrefix; if (defaultVolumeUnit.SiUnitName != null) { volumeUnit.Name = defaultVolumeUnit.SiUnitName.Value; } if (Math.Abs(defaultVolumeUnit.ConversionFactor - 1) > 1e-9) //need to create conversion units { var convBasedUnit = Exchanger.TargetRepository.Instances.New <IfcConversionBasedUnit>(); var dimensionalUnits = Exchanger.TargetRepository.Instances.New <IfcDimensionalExponents>(); dimensionalUnits.LengthExponent = 3; convBasedUnit.Dimensions = dimensionalUnits; var measureWithUnit = Exchanger.TargetRepository.Instances.New <IfcMeasureWithUnit>(); measureWithUnit.ValueComponent = new IfcRatioMeasure(defaultVolumeUnit.ConversionFactor); measureWithUnit.UnitComponent = volumeUnit; convBasedUnit.ConversionFactor = measureWithUnit; convBasedUnit.UnitType = volumeUnit.UnitType; convBasedUnit.Name = defaultVolumeUnit.UserDefinedSiUnitName; } } }
public void ArbitraryClosedProfileDefWithIncorrectPlacementTest() { using (var model = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel)) { using (var txn = model.BeginTransaction("Create Column")) { IfcProject project = model.Instances.New <IfcProject>(); project.Initialize(ProjectUnits.SIUnitsUK); project.Name = "Test Project"; IfcColumn col = model.Instances.New <IfcColumn>(); col.Name = "Column With ArbitraryClosedProfileDef"; //Creating IfcArbitraryClosedProfileDef that will contain IfcCompositeCurve IfcArbitraryClosedProfileDef arbClosedProf = model.Instances.New <IfcArbitraryClosedProfileDef>(); //To create IfcArbitraryClosedProfileDef, we'll need to create IfcCompositeCurve //Creating IfcCompositeCurve IfcCompositeCurve myCompCurve = model.Instances.New <IfcCompositeCurve>(); //To Create IfcCompositeCurve, We'll need to create IfcCompositeCurveSegment //create IfcCompositeCurveSegment (polyline) IfcCompositeCurveSegment polylineSeg = model.Instances.New <IfcCompositeCurveSegment>(); //create IfcCompositeCurveSegment (arc) IfcCompositeCurveSegment arcSeg = model.Instances.New <IfcCompositeCurveSegment>(); //Creating IfcPolyline that will be the parent curve for IfcCompositeCurveSegment "polylineSeg" IfcPolyline myPolyline = model.Instances.New <IfcPolyline>(); //Creating Points to build the IfcPolyline IfcCartesianPoint p0 = model.Instances.New <IfcCartesianPoint>(); p0.SetXY(200, 100); IfcCartesianPoint p1 = model.Instances.New <IfcCartesianPoint>(); p1.SetXY(0, 100); IfcCartesianPoint p2 = model.Instances.New <IfcCartesianPoint>(); p2.SetXY(0, 0); IfcCartesianPoint p3 = model.Instances.New <IfcCartesianPoint>(); p3.SetXY(400, 0); IfcCartesianPoint p4 = model.Instances.New <IfcCartesianPoint>(); p4.SetXY(400, 600); IfcCartesianPoint p5 = model.Instances.New <IfcCartesianPoint>(); p5.SetXY(0, 600); IfcCartesianPoint p6 = model.Instances.New <IfcCartesianPoint>(); p6.SetXY(0, 500); IfcCartesianPoint p7 = model.Instances.New <IfcCartesianPoint>(); p7.SetXY(200, 500); //Adding points to the polyline myPolyline.Points.Add(p0); myPolyline.Points.Add(p1); myPolyline.Points.Add(p2); myPolyline.Points.Add(p3); myPolyline.Points.Add(p4); myPolyline.Points.Add(p5); myPolyline.Points.Add(p6); myPolyline.Points.Add(p7); //Assigning myPolyline to the IfcCompositeCurveSegment polylineSeg polylineSeg.ParentCurve = myPolyline; //Creating Arc using IfcTrimmedCurve IfcTrimmedCurve myArc = model.Instances.New <IfcTrimmedCurve>(); //To create IfcTrimmedCurve, We'll need to create IfcCircle and trim it using IfcTrimmingSelect IfcCircle myCirc = model.Instances.New <IfcCircle>(); myCirc.Radius = 213.554; IfcCartesianPoint cP = model.Instances.New <IfcCartesianPoint>(); cP.SetXY(125.1312, 300); //this should really be a 3D point IfcAxis2Placement3D plcmnt = model.Instances.New <IfcAxis2Placement3D>(); plcmnt.Location = cP; plcmnt.RefDirection = model.Instances.New <IfcDirection>(); plcmnt.RefDirection.SetXY(0, 1);//this should eb a 3D axis myCirc.Position = plcmnt; myArc.BasisCurve = myCirc; IfcTrimmingSelect v1 = p7; IfcTrimmingSelect v2 = p0; myArc.Trim1.Add(v1); myArc.Trim2.Add(v2); arcSeg.ParentCurve = myArc; //Adding the created two IfcCompositeCurveSegments to the IfcCompositeCurve myCompCurve.Segments.Add(arcSeg); myCompCurve.Segments.Add(polylineSeg); //Assigning IfcCompositeCurve "myCompCurve" to the IfcArbitraryClosedProfileDef arbClosedProf.OuterCurve = myCompCurve; arbClosedProf.ProfileType = IfcProfileTypeEnum.AREA; //model as a swept area solid IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>(); body.Depth = 2000; body.SweptArea = arbClosedProf; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); txn.Commit(); var solid = _xbimGeometryCreator.CreateSolid(body); Assert.IsTrue((int)solid.Volume == 239345450); } } }