/// <summary> /// Add the document references to the IfcDocumentInformation object /// </summary> /// <param name="row">COBieDocumentRow holding row data</param> /// <param name="ifcDocumentInformation">IfcDocumentInformation object to add references too</param> private void AddDocumentReference(COBieDocumentRow row, IfcDocumentInformation ifcDocumentInformation) { if (ValidateString(row.File)) { //get locations, assume we have the same number of locations and document names List <string> strLocationValues = null; if (ValidateString(row.Directory)) { strLocationValues = SplitString(row.Directory, ':'); } List <string> strNameValues = SplitString(row.File, ':'); //see if we have a location match to every document name if ((strLocationValues != null) && (strNameValues.Count != strLocationValues.Count)) { strLocationValues = null; //cannot match locations to document so just supply document names } //create the Document References if (strNameValues.Count > 0) { IfcDocumentReference[] ifcDocumentReferences = new IfcDocumentReference[strNameValues.Count]; int i = 0; foreach (string name in strNameValues) { ifcDocumentReferences[i] = Model.Instances.New <IfcDocumentReference>(dr => { dr.Name = name; }); if (strLocationValues != null) { ifcDocumentReferences[i].Location = strLocationValues[i]; } i++; } ifcDocumentInformation.SetDocumentReferences(true, ifcDocumentReferences); } } }
internal static void GenerateData(STPModelData md, IfcBuilding building,bool assembly) { IfcDocumentReference documentReference = new IfcDocumentReference(md, "", "MyReinforcementCode", "MyCodeISO3766", "", null); IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(md.Project, documentReference); associatesDocument.GlobalId = "1R7R97$uLAAv4wci$KGwn8"; IfcMaterial material = new IfcMaterial(md, "ReinforcingSteel", "", ""); List<Point3d> points = new List<Point3d>() { new Point3d(-69.0, 0.0, -122.0), new Point3d(-69.0, 0.0, -79.0), new Point3d(-54.9411254969541, 0.0, -45.0588745030455), new Point3d(-21.0, 0.0, -31.0), new Point3d(21.0, 0.0, -31.0), new Point3d(54.9411254969541, 0.0, -45.0588745030455), new Point3d(69.0, 0.0, -78.9999999999999), new Point3d(69.0, 0.00000000000000089, -321.0), new Point3d(54.9939785957165, 1.21791490472034, -354.941125496954), new Point3d(21.1804517666074, 4.15822158551252, -369.0), new Point3d(-20.6616529376114, 7.79666547283599, -369.0), new Point3d(-54.4751797667207, 10.7369721536282, -354.941125496954), new Point3d(-68.4812011710042, 11.9548870583485, -321.0), new Point3d(-69.0, 12.0, -79.0), new Point3d(-54.9411254969541, 12.0, -45.0588745030455), new Point3d(-21.0, 12.0, -31.0), new Point3d(21.0, 12.0, -31.0), new Point3d(54.9411254969541, 12.0, -45.0588745030455), new Point3d(69.0, 12.0, -78.9999999999999),new Point3d(69.0, 12.0, -122.0), }; PolyCurve pc = new PolyCurve(); pc.Append(new Line(points[0],points[1])); pc.Append(new Arc(points[1],points[2],points[3] )); pc.Append(new Line(points[3],points[4])); pc.Append(new Arc(points[4],points[5],points[6] )); pc.Append(new Line(points[6],points[7])); pc.Append(new Arc(points[7],points[8],points[9] )); pc.Append(new Line(points[9],points[10])); pc.Append(new Arc(points[10],points[11],points[12] )); pc.Append(new Line(points[12],points[13])); pc.Append(new Arc(points[13],points[14],points[15] )); pc.Append(new Line(points[15],points[16])); pc.Append(new Arc(points[16],points[17],points[18] )); pc.Append(new Line(points[18],points[19])); IfcBoundedCurve directrix = IfcBoundedCurve.ConvertCurve(md,pc); double barDiameter = 12, area = Math.PI * Math.Pow( barDiameter,2) / 4; IfcSweptDiskSolid sweptDiskSolid = new IfcSweptDiskSolid(directrix, barDiameter/2.0, 0); IfcRepresentationMap representationMap = new IfcRepresentationMap(sweptDiskSolid); string shapeCode = ""; //Todo IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(md, "12 Diameter Ligature", IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null) { GlobalId = "0jMRtfHYXE7u4s_CQ2uVE9", MaterialSelect = material, RepresentationMaps = new List<IfcRepresentationMap>() { representationMap} }; reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j"; reinforcingBarType.Material.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6"; if (assembly) { IfcMaterial concrete = new IfcMaterial(md,"Concrete","","Concrete"); string name = "400x200RC"; IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(md, name, 400, 200); IfcMaterialProfile materialProfile = new IfcMaterialProfile(md,name,"",concrete,rectangleProfileDef,0,""); IfcBeamType beamType = new IfcBeamType(name, materialProfile, IfcBeamTypeEnum.BEAM) { GlobalId = "3bdpqVuWTCbxJ2S3ODYv6q"}; beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg"; beamType.Material.Associates.GlobalId = "2ZEgyI2v184hwa$_diRqS9"; IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(building, beamType, new Line(0, 0, 0, 0, 5000, 0), Vector3d.ZAxis, IfcCardinalPointReference.TOPMID, null) { GlobalId = "1yjQ2DwLnCC8k3i3X6D_ut" }; beamStandardCase.Material.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY"; IfcElementAssembly elementAssembly = new IfcElementAssembly(beamStandardCase, IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT) { GlobalId = "0Q1tCJWdj4kOkZUg7rkf2h" }; List<string> ids = new List<string>() { "0ohBfsArr3ruXYxacT4yl5","3YrK7RbE122fNRsP5djFAe","0wxAc63nj5AezFhfks7wLL","0bsov2wZL6tRRZmKy4vuUU","3qrgfIBb92ZegJTle7jou3","16m6R3JeT83fJPCze2yU$a","2SGIIYjSbCuu3HVwoLt1yh","0PsLby6eL8_hVEt4QwK0lZ","1325VJou5AngWp1djcV0hL","20zj_$BcH74xRgR4bDrLNb","3M4SfEMtHEJukgZR4hw$eV","23BYnIaOLBZPVTrKVEDJiy","2XulRByDL8ugyo4Uqv9rJr","2xvQMSga96XOT3VeCS6ZsK","2gUE6_w3j77f8YJGz_2RMl","0J0dRL4tT93REAabfASDom","048RJ151b81PqODsTMD4EA","3hXx9Kb6b5bvjgr9pwvpz0","0FmUHg8ZX0ZfY$0f5nkM2l","2_zvpwRdvAuRiTlHXX$Qp8","1mhkXHKfX6PxdS2vZn17wX","0CeIQzUqP5qOOeAjMtH2OX","3shtoAQL5BAhvwA_1Ph$lC","22j4RNKqD2IBRDGig5eaCF","3Wvu6qGJH4ChhTV3pl9CGh","37Qrf07Iz3tRMbSxEA4ynH","2gelqZ1Wv8BvCy6TstVGkd","1Q21dHc_X7eRppCHrT69Vb","0e6Wc08NLD59ueqCAK1gxp","3xdMOSZMj3cBOV_QTbXZha","1r_U9JTkHDWwkv_nfWFHVe","29I7_S2fT3WRD4zPH4YjmD","0$ciATTaP17PJMHQD0$N3Y","1irBeCCUf82wdGg7qTPCbW" }; int jcounter = 0; for (int icounter = 25; icounter < 5000; icounter += 150) { IfcElement element = reinforcingBarType.GenerateMappedItemElement(elementAssembly, new Plane(new Point3d(0, icounter, 0), Vector3d.XAxis, Vector3d.YAxis)); element.GlobalId = ids[jcounter++]; } elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU"; } else { IfcElement element = reinforcingBarType.GenerateMappedItemElement(building, Plane.WorldXY); element.GlobalId = "0WUveBtSTDbunNjDLsuRn$"; } }
/// <summary> /// Get the file directory/location /// </summary> /// <param name="ifcDocumentReference">Document Reference Object</param> /// <returns>string</returns> private string GetFileDirectory(IfcDocumentReference ifcDocumentReference) { if (ifcDocumentReference == null) { return(null); } if (!string.IsNullOrEmpty(ifcDocumentReference.Location)) { return(ifcDocumentReference.Location); } return(null); }
/// <summary> /// Convert a IfcDocumentReference to Document /// </summary> /// <param name="ifcDocumentReference">Document Reference Object</param> /// <param name="document">Document Object</param> /// <returns>Document</returns> private Document ConvertToDocument(IfcDocumentReference ifcDocumentReference, IfcDocumentInformation ifcDocumentInformation) { string name = GetName(ifcDocumentInformation) ?? GetName(ifcDocumentReference); //fail to get from IfcDocumentReference, so try assign a default if (string.IsNullOrEmpty(name)) { name = "Document"; } //check for duplicates, if found add a (#) => "DocName(1)", if none return name unchanged name = GetNextName(name); var document = new Document(); document.Name = name; document.CreatedBy = ifcDocumentInformation != null?GetCreatedBy(ifcDocumentInformation) : null; document.CreatedOn = ifcDocumentInformation != null?GetCreatedOn(ifcDocumentInformation) : null; document.Categories = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.Purpose)) ? new List <Category>(new[] { new Category { Code = ifcDocumentInformation.Purpose } }) : null; //ApprovalBy will be reset to a string field as ContactKey field is incorrect but for now fill ContactKey.email //document.ApprovalBy = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.IntendedUse)) ? new ContactKey() { Email = ifcDocumentInformation.IntendedUse } : null; document.ApprovalBy = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.IntendedUse)) ? ifcDocumentInformation.IntendedUse : null; //once fixed document.Stage = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.Scope)) ? ifcDocumentInformation.Scope : null; document.Directory = GetFileDirectory(ifcDocumentReference); document.File = GetFileName(ifcDocumentReference); document.ExternalSystem = null; document.ExternalEntity = ifcDocumentReference.GetType().Name; document.ExternalId = null; document.Description = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.Description)) ? ifcDocumentInformation.Description.ToString() : null; document.Reference = (ifcDocumentInformation != null) && (ifcDocumentInformation.DocumentId != null) && (ifcDocumentInformation.DocumentId.Value != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.DocumentId.Value.ToString())) ? ifcDocumentInformation.DocumentId.Value.ToString() : null; Helper.DocumentProgress.Add(document); return(document); }
/// <summary> /// Get Name from IfcDocumentReference /// </summary> /// <param name="ifcDocumentReference">Document Reference Object</param> /// <returns>string or null</returns> private string GetName(IfcDocumentReference ifcDocumentReference) { if (ifcDocumentReference == null) { return(null); } if (!string.IsNullOrEmpty(ifcDocumentReference.Name)) { return(ifcDocumentReference.Name); } if (!string.IsNullOrEmpty(ifcDocumentReference.Location)) { return(Path.GetFileNameWithoutExtension(ifcDocumentReference.Location)); } //we ignore ItemReference, "which refers to a system interpretable position within the document" from http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcexternalreferenceresource/lexical/ifcdocumentreference.htm return(null); }
/// <summary> /// Get file name /// </summary> /// <param name="ifcDocumentReference">Document Reference Object</param> /// <returns>string</returns> private string GetFileName(IfcDocumentReference ifcDocumentReference) { if (ifcDocumentReference == null) { return(null); } if (!string.IsNullOrEmpty(ifcDocumentReference.Name)) { return(ifcDocumentReference.Name); } if (!string.IsNullOrEmpty(ifcDocumentReference.Location)) { try { return(Path.GetFileName(ifcDocumentReference.Location)); } catch (Exception) //if exception just return the stored string { return(ifcDocumentReference.Location); } } return(null); }
/// <summary> /// Get the file information for the document attached to the ifcRelAssociatesDocument /// </summary> /// <param name="ifcRelAssociatesDocument">IfcRelAssociatesDocument object</param> /// <returns>FileInformation structure </returns> private FileInformation GetFileInformation(IfcRelAssociatesDocument ifcRelAssociatesDocument) { FileInformation DocInfo = new FileInformation() { Name = DEFAULT_STRING, Location = DEFAULT_STRING }; string value = ""; if (ifcRelAssociatesDocument != null) { //test for single document IfcDocumentReference ifcDocumentReference = ifcRelAssociatesDocument.RelatingDocument as IfcDocumentReference; if (ifcDocumentReference != null) { //this is possibly incorrect, think it references information within a document value = ifcDocumentReference.ItemReference.ToString(); if (!string.IsNullOrEmpty(value)) { DocInfo.Name = value; } value = ifcDocumentReference.Location.ToString(); if (!string.IsNullOrEmpty(value)) { DocInfo.Location = value; } } else //test for a document list { IfcDocumentInformation ifcDocumentInformation = ifcRelAssociatesDocument.RelatingDocument as IfcDocumentInformation; if (ifcDocumentInformation != null) { IEnumerable <IfcDocumentReference> ifcDocumentReferences = ifcDocumentInformation.DocumentReferences; if (ifcDocumentReferences != null) { List <string> strNameValues = new List <string>(); List <string> strLocationValues = new List <string>(); foreach (IfcDocumentReference docRef in ifcDocumentReferences) { //get file name value = docRef.ItemReference.ToString(); if (!string.IsNullOrEmpty(value)) { strNameValues.Add(value); } else { value = docRef.Name.ToString(); if (!string.IsNullOrEmpty(value)) { strNameValues.Add(value); } } //get file location value = docRef.Location.ToString(); if ((!string.IsNullOrEmpty(value)) && (!strNameValues.Contains(value))) { strLocationValues.Add(value); } } //set values to return if (strNameValues.Count > 0) { DocInfo.Name = COBieXBim.JoinStrings(':', strNameValues); } if (strLocationValues.Count > 0) { DocInfo.Location = COBieXBim.JoinStrings(':', strLocationValues); } } } } } return(DocInfo); }
internal static void GenerateInstance(IfcBuilding building, bool assembly) { DatabaseIfc db = building.Database; IfcDocumentReference documentReference = new IfcDocumentReference(db) { Name = "MyReinforcementCode", Identification = "MyCodeISO3766" }; IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(db.Project, documentReference) { GlobalId = "1R7R97$uLAAv4wci$KGwn8" }; IfcMaterial material = new IfcMaterial(db, "ReinforcingSteel"); List <Tuple <double, double, double> > points = new List <Tuple <double, double, double> >() { new Tuple <double, double, double>(-69.0, 0.0, -122.0), new Tuple <double, double, double>(-69.0, 0.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 0.0, -31.0), new Tuple <double, double, double>(21.0, 0.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 0.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 0.00000000000000089, -321.0), new Tuple <double, double, double>(54.9939785957165, 1.21791490472034, -354.941125496954), new Tuple <double, double, double>(21.1804517666074, 4.15822158551252, -369.0), new Tuple <double, double, double>(-20.6616529376114, 7.79666547283599, -369.0), new Tuple <double, double, double>(-54.4751797667207, 10.7369721536282, -354.941125496954), new Tuple <double, double, double>(-68.4812011710042, 11.9548870583485, -321.0), new Tuple <double, double, double>(-69.0, 12.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 12.0, -31.0), new Tuple <double, double, double>(21.0, 12.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 12.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 12.0, -122.0), }; IfcBoundedCurve directrix = null; if (db.Release == ReleaseVersion.IFC2x3) { directrix = new IfcPolyline(db, points); } else { List <IfcSegmentIndexSelect> segments = new List <IfcSegmentIndexSelect>(); segments.Add(new IfcLineIndex(1, 2)); segments.Add(new IfcArcIndex(2, 3, 4)); segments.Add(new IfcLineIndex(4, 5)); segments.Add(new IfcArcIndex(5, 6, 7)); segments.Add(new IfcLineIndex(7, 8)); segments.Add(new IfcArcIndex(8, 9, 10)); segments.Add(new IfcLineIndex(10, 11)); segments.Add(new IfcArcIndex(11, 12, 13)); segments.Add(new IfcLineIndex(13, 14)); segments.Add(new IfcArcIndex(14, 15, 16)); segments.Add(new IfcLineIndex(16, 17)); segments.Add(new IfcArcIndex(17, 18, 19)); segments.Add(new IfcLineIndex(19, 20)); directrix = new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, points), segments); } double barDiameter = 12, area = Math.PI * Math.Pow(barDiameter, 2) / 4; IfcSweptDiskSolid sweptDiskSolid = new IfcSweptDiskSolid(directrix, barDiameter / 2.0); IfcRepresentationMap representationMap = new IfcRepresentationMap(sweptDiskSolid); string shapeCode = ""; //Todo IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(db, "12 Diameter Ligature", IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null) { GlobalId = "0jMRtfHYXE7u4s_CQ2uVE9", MaterialSelect = material }; reinforcingBarType.RepresentationMaps.Add(representationMap); db.Context.AddDeclared(reinforcingBarType); if (assembly) { IfcMaterial concrete = new IfcMaterial(db, "Concrete") { Category = "Concrete" }; string name = "400x200RC"; IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(db, name, 200, 400); IfcMaterialProfile materialProfile = new IfcMaterialProfile(name, concrete, rectangleProfileDef); IfcBeamType beamType = new IfcBeamType(name, materialProfile, IfcBeamTypeEnum.BEAM); db.Context.AddDeclared(beamType); IfcMaterialProfileSet materialProfileSet = beamType.MaterialSelect as IfcMaterialProfileSet; IfcBeam beam = new IfcBeam(building, new IfcLocalPlacement(building.Placement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0))), null) { Description = "Reinforced Beam" }; IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(beam, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.TOPMID), new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 0, 1, 0), new IfcDirection(db, -1, 0, 0)), 5000) { GlobalId = "1yjQ2DwLnCC8k3i3X6D_ut", RelatingType = beamType }; IfcElementAssembly elementAssembly = new IfcElementAssembly(beam, IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT); List <string> ids = new List <string>() { "0ohBfsArr3ruXYxacT4yl5", "3YrK7RbE122fNRsP5djFAe", "0wxAc63nj5AezFhfks7wLL", "0bsov2wZL6tRRZmKy4vuUU", "3qrgfIBb92ZegJTle7jou3", "16m6R3JeT83fJPCze2yU$a", "2SGIIYjSbCuu3HVwoLt1yh", "0PsLby6eL8_hVEt4QwK0lZ", "1325VJou5AngWp1djcV0hL", "20zj_$BcH74xRgR4bDrLNb", "3M4SfEMtHEJukgZR4hw$eV", "23BYnIaOLBZPVTrKVEDJiy", "2XulRByDL8ugyo4Uqv9rJr", "2xvQMSga96XOT3VeCS6ZsK", "2gUE6_w3j77f8YJGz_2RMl", "0J0dRL4tT93REAabfASDom", "048RJ151b81PqODsTMD4EA", "3hXx9Kb6b5bvjgr9pwvpz0", "0FmUHg8ZX0ZfY$0f5nkM2l", "2_zvpwRdvAuRiTlHXX$Qp8", "1mhkXHKfX6PxdS2vZn17wX", "0CeIQzUqP5qOOeAjMtH2OX", "3shtoAQL5BAhvwA_1Ph$lC", "22j4RNKqD2IBRDGig5eaCF", "3Wvu6qGJH4ChhTV3pl9CGh", "37Qrf07Iz3tRMbSxEA4ynH", "2gelqZ1Wv8BvCy6TstVGkd", "1Q21dHc_X7eRppCHrT69Vb", "0e6Wc08NLD59ueqCAK1gxp", "3xdMOSZMj3cBOV_QTbXZha", "1r_U9JTkHDWwkv_nfWFHVe", "29I7_S2fT3WRD4zPH4YjmD", "0$ciATTaP17PJMHQD0$N3Y", "1irBeCCUf82wdGg7qTPCbW" }; int jcounter = 0; for (int icounter = 25; icounter < 5000; icounter += 150) { IfcElement element = reinforcingBarType.GenerateMappedItemElement(elementAssembly, new IfcCartesianTransformationOperator3D(db) { LocalOrigin = new IfcCartesianPoint(db, 0, icounter, 0) }); //Unique ids assigned to generate constant IfcScript sample files, remove otherwise element.GlobalId = ids[jcounter++]; } //Unique ids assigned to generate constant IfcScript sample files, remove otherwise beam.GlobalId = "1_KSmTR8T8bO37iRs24GkM"; beamType.GlobalId = "3bdpqVuWTCbxJ2S3ODYv6q"; beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg"; beamType.MaterialSelect.Associates.GlobalId = "2ZEgyI2v184hwa$_diRqS9"; beamStandardCase.MaterialSelect.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY"; elementAssembly.GlobalId = "0Q1tCJWdj4kOkZUg7rkf2h"; elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU"; beam.IsDecomposedBy[0].GlobalId = "1b1SnKocD0WRevlg8Aqhj5"; } else { IfcElement element = reinforcingBarType.GenerateMappedItemElement(building, new IfcCartesianTransformationOperator3D(db)); //Unique ids assigned to generate constant IfcScript sample files, remove otherwise element.GlobalId = "0WUveBtSTDbunNjDLsuRn$"; } //Unique ids assigned to generate constant IfcScript sample files, remove otherwise reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j"; reinforcingBarType.MaterialSelect.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6"; }
internal static void GenerateData(STPModelData md, IfcBuilding building, bool assembly) { IfcDocumentReference documentReference = new IfcDocumentReference(md, "", "MyReinforcementCode", "MyCodeISO3766", "", null); IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(md.Project, documentReference); associatesDocument.GlobalId = "1R7R97$uLAAv4wci$KGwn8"; IfcMaterial material = new IfcMaterial(md, "ReinforcingSteel", "", ""); List <Point3d> points = new List <Point3d>() { new Point3d(-69.0, 0.0, -122.0), new Point3d(-69.0, 0.0, -79.0), new Point3d(-54.9411254969541, 0.0, -45.0588745030455), new Point3d(-21.0, 0.0, -31.0), new Point3d(21.0, 0.0, -31.0), new Point3d(54.9411254969541, 0.0, -45.0588745030455), new Point3d(69.0, 0.0, -78.9999999999999), new Point3d(69.0, 0.00000000000000089, -321.0), new Point3d(54.9939785957165, 1.21791490472034, -354.941125496954), new Point3d(21.1804517666074, 4.15822158551252, -369.0), new Point3d(-20.6616529376114, 7.79666547283599, -369.0), new Point3d(-54.4751797667207, 10.7369721536282, -354.941125496954), new Point3d(-68.4812011710042, 11.9548870583485, -321.0), new Point3d(-69.0, 12.0, -79.0), new Point3d(-54.9411254969541, 12.0, -45.0588745030455), new Point3d(-21.0, 12.0, -31.0), new Point3d(21.0, 12.0, -31.0), new Point3d(54.9411254969541, 12.0, -45.0588745030455), new Point3d(69.0, 12.0, -78.9999999999999), new Point3d(69.0, 12.0, -122.0), }; PolyCurve pc = new PolyCurve(); pc.Append(new Line(points[0], points[1])); pc.Append(new Arc(points[1], points[2], points[3])); pc.Append(new Line(points[3], points[4])); pc.Append(new Arc(points[4], points[5], points[6])); pc.Append(new Line(points[6], points[7])); pc.Append(new Arc(points[7], points[8], points[9])); pc.Append(new Line(points[9], points[10])); pc.Append(new Arc(points[10], points[11], points[12])); pc.Append(new Line(points[12], points[13])); pc.Append(new Arc(points[13], points[14], points[15])); pc.Append(new Line(points[15], points[16])); pc.Append(new Arc(points[16], points[17], points[18])); pc.Append(new Line(points[18], points[19])); IfcBoundedCurve directrix = IfcBoundedCurve.ConvertCurve(md, pc); double barDiameter = 12, area = Math.PI * Math.Pow(barDiameter, 2) / 4; IfcSweptDiskSolid sweptDiskSolid = new IfcSweptDiskSolid(directrix, barDiameter / 2.0, 0); IfcRepresentationMap representationMap = new IfcRepresentationMap(sweptDiskSolid); string shapeCode = ""; //Todo IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(md, new IfcElemTypeParams("0jMRtfHYXE7u4s_CQ2uVE9", "12 Diameter Ligature", "", "", ""), material, representationMap, null, IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null); reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j"; reinforcingBarType.Material.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6"; if (assembly) { IfcMaterial concrete = new IfcMaterial(md, "Concrete", "", "Concrete"); string name = "400x200RC"; IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(md, IfcProfileTypeEnum.AREA, name, null, 400, 200); IfcMaterialProfile materialProfile = new IfcMaterialProfile(md, name, "", concrete, rectangleProfileDef, 0, ""); IfcBeamType beamType = new IfcBeamType(md, new IfcElemTypeParams("3bdpqVuWTCbxJ2S3ODYv6q", name, "", "", ""), materialProfile, null, IfcBeamTypeEnum.BEAM); beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg"; beamType.Material.Associates.GlobalId = "2ZEgyI2v184hwa$_diRqS9"; IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(building, new IfcElemParams("1yjQ2DwLnCC8k3i3X6D_ut", "", "", "", ""), beamType, new Line(0, 0, 0, 0, 5000, 0), Vector3d.ZAxis, IfcCardinalPointReference.TOPMID, null); beamStandardCase.Material.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY"; IfcElementAssembly elementAssembly = new IfcElementAssembly(beamStandardCase, new IfcElemParams("0Q1tCJWdj4kOkZUg7rkf2h", "", "", "", ""), IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT); List <string> ids = new List <string>() { "0ohBfsArr3ruXYxacT4yl5", "3YrK7RbE122fNRsP5djFAe", "0wxAc63nj5AezFhfks7wLL", "0bsov2wZL6tRRZmKy4vuUU", "3qrgfIBb92ZegJTle7jou3", "16m6R3JeT83fJPCze2yU$a", "2SGIIYjSbCuu3HVwoLt1yh", "0PsLby6eL8_hVEt4QwK0lZ", "1325VJou5AngWp1djcV0hL", "20zj_$BcH74xRgR4bDrLNb", "3M4SfEMtHEJukgZR4hw$eV", "23BYnIaOLBZPVTrKVEDJiy", "2XulRByDL8ugyo4Uqv9rJr", "2xvQMSga96XOT3VeCS6ZsK", "2gUE6_w3j77f8YJGz_2RMl", "0J0dRL4tT93REAabfASDom", "048RJ151b81PqODsTMD4EA", "3hXx9Kb6b5bvjgr9pwvpz0", "0FmUHg8ZX0ZfY$0f5nkM2l", "2_zvpwRdvAuRiTlHXX$Qp8", "1mhkXHKfX6PxdS2vZn17wX", "0CeIQzUqP5qOOeAjMtH2OX", "3shtoAQL5BAhvwA_1Ph$lC", "22j4RNKqD2IBRDGig5eaCF", "3Wvu6qGJH4ChhTV3pl9CGh", "37Qrf07Iz3tRMbSxEA4ynH", "2gelqZ1Wv8BvCy6TstVGkd", "1Q21dHc_X7eRppCHrT69Vb", "0e6Wc08NLD59ueqCAK1gxp", "3xdMOSZMj3cBOV_QTbXZha", "1r_U9JTkHDWwkv_nfWFHVe", "29I7_S2fT3WRD4zPH4YjmD", "0$ciATTaP17PJMHQD0$N3Y", "1irBeCCUf82wdGg7qTPCbW" }; int jcounter = 0; for (int icounter = 25; icounter < 5000; icounter += 150) { IfcElemParams ep = new IfcElemParams(ids[jcounter++], "", "", "", ""); reinforcingBarType.GenerateMappedItemElement(elementAssembly, new Plane(new Point3d(0, icounter, 0), Vector3d.XAxis, Vector3d.YAxis), ep); } elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU"; } else { reinforcingBarType.GenerateMappedItemElement(building, Plane.WorldXY, new IfcElemParams("0WUveBtSTDbunNjDLsuRn$", "", "", "", "")); } }
private static void CreateSimpleProperty(XbimModel model, IfcWallStandardCase wall, IfcOwnerHistory ifcOwnerHistory) { IfcPropertySingleValue ifcPropertySingleValue = model.Instances.New <IfcPropertySingleValue>(psv => { psv.Name = "IfcPropertySingleValue:Time"; psv.Description = ""; psv.NominalValue = new IfcTimeMeasure(150.0); psv.Unit = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.TIMEUNIT; siu.Name = IfcSIUnitName.SECOND; siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 0; de.MassExponent = 0; de.TimeExponent = 1; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); }); }); IfcPropertyEnumeratedValue ifcPropertyEnumeratedValue = model.Instances.New <IfcPropertyEnumeratedValue>(pev => { pev.Name = "IfcPropertyEnumeratedValue:Music"; pev.EnumerationReference = model.Instances.New <IfcPropertyEnumeration>(pe => { pe.Name = "Notes"; pe.EnumerationValues.Add(new IfcLabel("Do")); pe.EnumerationValues.Add(new IfcLabel("Re")); pe.EnumerationValues.Add(new IfcLabel("Mi")); pe.EnumerationValues.Add(new IfcLabel("Fa")); pe.EnumerationValues.Add(new IfcLabel("So")); pe.EnumerationValues.Add(new IfcLabel("La")); pe.EnumerationValues.Add(new IfcLabel("Ti")); }); pev.EnumerationValues.Add(new IfcLabel("Do")); pev.EnumerationValues.Add(new IfcLabel("Re")); pev.EnumerationValues.Add(new IfcLabel("Mi")); }); IfcPropertyBoundedValue ifcPropertyBoundedValue = model.Instances.New <IfcPropertyBoundedValue>(pbv => { pbv.Name = "IfcPropertyBoundedValue:Mass"; pbv.Description = ""; pbv.UpperBoundValue = new IfcMassMeasure(5000.0); pbv.LowerBoundValue = new IfcMassMeasure(1000.0); pbv.Unit = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.MASSUNIT; siu.Name = IfcSIUnitName.GRAM; siu.Prefix = IfcSIPrefix.KILO; siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 0; de.MassExponent = 1; de.TimeExponent = 0; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); }); }); List <IfcReal> definingValues = new List <IfcReal>() { new IfcReal(100.0), new IfcReal(200.0), new IfcReal(400.0), new IfcReal(800.0), new IfcReal(1600.0), new IfcReal(3200.0), }; List <IfcReal> definedValues = new List <IfcReal>() { new IfcReal(20.0), new IfcReal(42.0), new IfcReal(46.0), new IfcReal(56.0), new IfcReal(60.0), new IfcReal(65.0), }; IfcPropertyTableValue ifcPropertyTableValue = model.Instances.New <IfcPropertyTableValue>(ptv => { ptv.Name = "IfcPropertyTableValue:Sound"; foreach (var item in definingValues) { ptv.DefiningValues.Add(item); } foreach (var item in definedValues) { ptv.DefinedValues.Add(item); } ptv.DefinedUnit = model.Instances.New <IfcContextDependentUnit>(cd => { cd.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 0; de.MassExponent = 0; de.TimeExponent = 0; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); cd.UnitType = IfcUnitEnum.FREQUENCYUNIT; cd.Name = "dB"; }); }); List <IfcLabel> listValues = new List <IfcLabel>() { new IfcLabel("Red"), new IfcLabel("Green"), new IfcLabel("Blue"), new IfcLabel("Pink"), new IfcLabel("White"), new IfcLabel("Black"), }; IfcPropertyListValue ifcPropertyListValue = model.Instances.New <IfcPropertyListValue>(plv => { plv.Name = "IfcPropertyListValue:Colours"; foreach (var item in listValues) { plv.ListValues.Add(item); } }); IfcMaterial IfcMaterial = model.Instances.New <IfcMaterial>(m => { m.Name = "Brick"; }); IfcPropertyReferenceValue ifcPRValueMaterial = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Material"; prv.PropertyReference = IfcMaterial; }); IfcPropertyReferenceValue ifcPRValuePerson = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Person"; prv.PropertyReference = ifcOwnerHistory.OwningUser.ThePerson; }); IfcDateAndTime ifcDateAndTime = model.Instances.New <IfcDateAndTime>(dt => { dt.DateComponent = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 25; cd.MonthComponent = 3; cd.YearComponent = 2013; }); dt.TimeComponent = model.Instances.New <IfcLocalTime>(lt => { lt.HourComponent = 10; lt.MinuteComponent = 30; lt.SecondComponent = 0; }); }); IfcPropertyReferenceValue ifcPRValueDateTime = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:DateAndTime"; prv.PropertyReference = ifcDateAndTime; }); IfcMaterialList ifcMaterialList = model.Instances.New <IfcMaterialList>(ml => { ml.Materials.Add(IfcMaterial); ml.Materials.Add(model.Instances.New <IfcMaterial>(m => { m.Name = "Cavity"; })); ml.Materials.Add(model.Instances.New <IfcMaterial>(m => { m.Name = "Block"; })); }); IfcPropertyReferenceValue ifcPRValueMatList = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:MaterialList"; prv.PropertyReference = ifcMaterialList; }); IfcPropertyReferenceValue ifcPRValueOrg = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Organization"; prv.PropertyReference = ifcOwnerHistory.OwningUser.TheOrganization; }); IfcPropertyReferenceValue ifcPRValueDate = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Date"; prv.PropertyReference = ifcDateAndTime.DateComponent; }); IfcPropertyReferenceValue ifcPRValueTime = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Time"; prv.PropertyReference = ifcDateAndTime.TimeComponent; }); IfcPropertyReferenceValue ifcPRValuePersonOrg = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:PersonOrganization"; prv.PropertyReference = ifcOwnerHistory.OwningUser; }); IfcMaterialLayer ifcMaterialLayer = model.Instances.New <IfcMaterialLayer>(ml => { ml.Material = IfcMaterial; ml.LayerThickness = 100.0; }); IfcPropertyReferenceValue ifcPRValueMatLayer = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:MaterialLayer"; prv.PropertyReference = ifcMaterialLayer; }); IfcDocumentReference ifcDocumentReference = model.Instances.New <IfcDocumentReference>(dr => { dr.Name = "Document"; dr.Location = "c://Documents//TheDoc.Txt"; }); IfcPropertyReferenceValue ifcPRValueRef = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Document"; prv.PropertyReference = ifcDocumentReference; }); IfcRegularTimeSeries ifcTimeSeries = model.Instances.New <IfcRegularTimeSeries>(ts => { ts.Name = "Regular Time Series"; ts.Description = "Time series of events"; ts.StartTime = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 01; cd.MonthComponent = 1; cd.YearComponent = 2013; }); ts.EndTime = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 01; cd.MonthComponent = 3; cd.YearComponent = 2013; }); ts.TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.CONTINUOUS; ts.DataOrigin = IfcDataOriginEnum.MEASURED; ts.TimeStep = 604800; //7 days in secs }); IfcPropertyReferenceValue ifcPRValueTimeSeries = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:TimeSeries"; prv.PropertyReference = ifcTimeSeries; }); IfcPostalAddress ifcAddress = model.Instances.New <IfcPostalAddress>(a => { a.InternalLocation = "Room 101"; a.SetAddressLines(new string[] { "12 New road", "DoxField" }); a.Town = "Sunderland"; a.PostalCode = "DL01 6SX"; }); IfcPropertyReferenceValue ifcPRValueAddress = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Address"; prv.PropertyReference = ifcAddress; }); IfcTelecomAddress IfcTelecomAddress = model.Instances.New <IfcTelecomAddress>(a => { a.SetTelephoneNumbers(new string[] { "01325 6589965" }); a.SetElectronicMailAddress(new string[] { "*****@*****.**" }); }); IfcPropertyReferenceValue ifcPRValueTelecom = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Telecom"; prv.PropertyReference = IfcTelecomAddress; }); IfcCostValue ifcCostValue = model.Instances.New <IfcCostValue>(cv => { cv.Name = "Cost Value"; cv.Description = ""; cv.Value = new IfcMonetaryMeasure(155.0); cv.ApplicableDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 02; cd.MonthComponent = 02; cd.YearComponent = 2013; }); cv.FixedUntilDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 31; cd.MonthComponent = 12; cd.YearComponent = 2013; }); cv.CostType = "Annual rate of return"; cv.Condition = ""; }); IfcPropertyReferenceValue ifcPRValueCostValue = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:CostValue"; prv.PropertyReference = ifcCostValue; }); IfcEnvironmentalImpactValue IfcEnvironmentalImpactValue = model.Instances.New <IfcEnvironmentalImpactValue>(cv => { cv.Name = "Environmental Impact"; cv.Description = ""; cv.Value = model.Instances.New <IfcMeasureWithUnit>(mwu => { mwu.ValueComponent = new IfcReal(111.0); mwu.UnitComponent = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.LENGTHUNIT; siu.Name = IfcSIUnitName.METRE; siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 1; de.MassExponent = 0; de.TimeExponent = 0; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); }); }); cv.ApplicableDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 02; cd.MonthComponent = 02; cd.YearComponent = 2013; }); cv.FixedUntilDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 31; cd.MonthComponent = 12; cd.YearComponent = 2013; }); cv.ImpactType = "Embodied energy"; cv.Category = IfcEnvironmentalImpactCategoryEnum.MANUFACTURE; }); IfcPropertyReferenceValue ifcPRValueEnvironmentalImpact = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:EnvironmentalImpact"; prv.PropertyReference = IfcEnvironmentalImpactValue; }); //lets create the IfcElementQuantity IfcPropertySet ifcPropertySet = model.Instances.New <IfcPropertySet>(ps => { ps.OwnerHistory = ifcOwnerHistory; ps.Name = "Test:IfcPropertySet"; ps.Description = "Property Set"; ps.HasProperties.Add(ifcPropertySingleValue); ps.HasProperties.Add(ifcPropertyEnumeratedValue); ps.HasProperties.Add(ifcPropertyBoundedValue); ps.HasProperties.Add(ifcPropertyTableValue); ps.HasProperties.Add(ifcPropertyListValue); ps.HasProperties.Add(ifcPRValueMaterial); ps.HasProperties.Add(ifcPRValuePerson); ps.HasProperties.Add(ifcPRValueDateTime); ps.HasProperties.Add(ifcPRValueMatList); ps.HasProperties.Add(ifcPRValueOrg); ps.HasProperties.Add(ifcPRValueDate); ps.HasProperties.Add(ifcPRValueTime); ps.HasProperties.Add(ifcPRValuePersonOrg); ps.HasProperties.Add(ifcPRValueMatLayer); ps.HasProperties.Add(ifcPRValueRef); ps.HasProperties.Add(ifcPRValueTimeSeries); ps.HasProperties.Add(ifcPRValueAddress); ps.HasProperties.Add(ifcPRValueTelecom); ps.HasProperties.Add(ifcPRValueCostValue); ps.HasProperties.Add(ifcPRValueEnvironmentalImpact); }); //need to create the relationship IfcRelDefinesByProperties ifcRelDefinesByProperties = model.Instances.New <IfcRelDefinesByProperties>(rdbp => { rdbp.OwnerHistory = ifcOwnerHistory; rdbp.Name = "Property Association"; rdbp.Description = "IfcPropertySet associated to wall"; rdbp.RelatedObjects.Add(wall); rdbp.RelatingPropertyDefinition = ifcPropertySet; }); }