private static void ProcessObjects(CostModel model, CostSchedule schedule, IEnumerable <TObjekt> objekty, Dictionary <string, ClassificationItem> jkso) { if (objekty == null || !objekty.Any()) { return; } foreach (var obj in objekty) { // root element of the cost schedule var rootItem = new CostItem(model) { Name = obj.Nazev, Description = obj.OPOPIS, Identifier = obj.Cislo }; schedule.CostItems.Add(rootItem); // additional properties can be stored in custom property sets rootItem["CZ_CostItem"] = new PropertySet(model); rootItem["CZ_CostItem"]["Charakteristika"] = new IfcText(obj.Charakteristika); rootItem["CZ_CostItem"]["DruhStavebniAkce"] = new IfcText(obj.DruhStavebniAkce); if (!string.IsNullOrWhiteSpace(obj.CisloJKSO)) { var jksoItem = jkso[obj.CisloJKSO]; rootItem.ClassificationItems.Add(jksoItem); } foreach (var soup in obj.SOUPIS) { var item = new CostItem(model) { Name = soup.Nazev, Identifier = soup.Cislo, Description = soup.RPOPIS }; rootItem.Children.Add(item); // classification hierarchy in IFC. Cost Items will be related to Classification Items var classificationMap = new Dictionary <string, ClassificationItem>(); if (soup.ZATRIDENI != null && soup.ZATRIDENI.Any()) { var rootClassificationName = GetClassificationName(soup); var rootClassification = new Classification(model, rootClassificationName); classificationMap = ConvertClassification(model, soup.ZATRIDENI, rootClassification.Children); } // next level of the cost breakdown structure ProcessParts(model, soup.DIL, item, classificationMap); } } }
private static void ProcessActors(CostModel model, CostSchedule schedule, IEnumerable <TSubjekt> subjekty) { if (subjekty == null || !subjekty.Any()) { return; } foreach (var subjekt in subjekty) { // actor will be assigned to schedule through IfcRelAssignsToActor var actor = new Actor(model, subjekt.Nazev); var role = GetRole(subjekt.Typ); if (role != IfcRoleEnum.USERDEFINED) { // prefered way is to use one of the predefined roles schedule.Actors.Add(actor, role); } else { // extensibility allows to use any string as a role schedule.Actors.Add(actor, subjekt.Typ.ToString()); } // actor can have person actor.Person = model.Create.Person(p => { p.GivenName = subjekt.Kontakt; }); // and organization actor.Organization = model.Create.Organization(o => { o.Identification = subjekt.ICO; o.Name = subjekt.Nazev; o.Addresses.Add(model.Create.PostalAddress(a => { a.AddressLines.Add(subjekt.Adresa); a.Town = subjekt.Misto; a.PostalCode = subjekt.PSC; a.Country = subjekt.Stat; })); o.Addresses.Add(model.Create.TelecomAddress(a => { a.ElectronicMailAddresses.Add(subjekt.Email); a.TelephoneNumbers.Add(subjekt.Telefon); })); }); // additional information can be stored using custom property set(s) actor["CZ_Actor"] = new PropertySet(model); actor["CZ_Actor"]["DIC"] = new IfcIdentifier(subjekt.DIC); } }
public static CostModel Convert(TeSoupis soupis) { unitCache.Clear(); // information about the application, person and organisation // who created the file var credentials = new XbimEditorCredentials { ApplicationDevelopersName = "Martin Cerny", ApplicationFullName = soupis.Zdroj.ToString(), ApplicationIdentifier = soupis.Zdroj.ToString(), ApplicationVersion = "1.0", //your user EditorsFamilyName = Environment.UserName, EditorsGivenName = "", EditorsOrganisationName = Environment.UserDomainName }; var stavba = soupis.STAVBA.FirstOrDefault(); var model = new CostModel(credentials, stavba.Nazev); using (var txn = model.BeginTransaction()) { // currency var costUnit = model.Create.MonetaryUnit(u => u.Currency = soupis.Mena.ToString()); model.Project.Units.Add(costUnit); // project information model.Project.LongName = stavba.SPOPIS; model.Project.Address = model.Create.PostalAddress(a => a.AddressLines.Add(stavba.Misto)); var jkso = ProcessJKSO(model, soupis); // process all sites foreach (var s in soupis.STAVBA) { // root element var schedule = new CostSchedule(model, s.Cislo); // subjects (client, supplier) ProcessActors(model, schedule, s.SUBJEKT); // schedule items and classification ProcessObjects(model, schedule, s.OBJEKT, jkso); } // commit changes txn.Commit(); return(model); } }
public void SimpleModelTest() { var credentials = new XbimEditorCredentials { ApplicationDevelopersName = "Martin Cerny", ApplicationFullName = "ORF tests", ApplicationIdentifier = "ORFT", ApplicationVersion = "4.0", //your user EditorsFamilyName = "Cerny", EditorsGivenName = "Martin", EditorsOrganisationName = "CAS" }; using (var model = new CostModel(credentials, "Example cost model")) { using (var txn = model.BeginTransaction()) { var lengthUnit = model.Create.SIUnit(u => { u.Name = Xbim.Ifc4.Interfaces.IfcSIUnitName.METRE; u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.LENGTHUNIT; }); var areaUnit = model.Create.SIUnit(u => { u.Name = Xbim.Ifc4.Interfaces.IfcSIUnitName.SQUARE_METRE; u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.AREAUNIT; }); var volumeUnit = model.Create.SIUnit(u => { u.Name = Xbim.Ifc4.Interfaces.IfcSIUnitName.CUBIC_METRE; u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.VOLUMEUNIT; }); var weightUnit = model.Create.SIUnit(u => { u.Name = Xbim.Ifc4.Interfaces.IfcSIUnitName.GRAM; u.Prefix = Xbim.Ifc4.Interfaces.IfcSIPrefix.KILO; u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.MASSUNIT; }); var timeUnit = model.Create.SIUnit(u => { u.Name = Xbim.Ifc4.Interfaces.IfcSIUnitName.SECOND; u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.TIMEUNIT; }); var costUnit = model.Create.MonetaryUnit(u => u.Currency = "CZK"); // project wide units assignment model.Project.Units.Add(lengthUnit); model.Project.Units.Add(areaUnit); model.Project.Units.Add(volumeUnit); model.Project.Units.Add(weightUnit); model.Project.Units.Add(timeUnit); model.Project.Units.Add(costUnit); var schedule = new CostSchedule(model, "Sample schedule"); var rootA = new CostItem(model) { Name = "Superstructure", Identifier = "A.1", Description = "Description of superstructure" }; var rootB = new CostItem(model) { Name = "Substructure", Identifier = "B.1", Description = "Description of substructure" }; schedule.CostItems.Add(rootA); schedule.CostItems.Add(rootB); var walls = new CostItem(model) { Name = "Walls", Identifier = "A.1.1", }; var floors = new CostItem(model) { Name = "Floors", Identifier = "A.1.2", }; var windows = new CostItem(model) { Name = "Windows", Identifier = "B.1.2", }; rootA.Children.Add(walls); rootA.Children.Add(floors); rootB.Children.Add(windows); walls.Quantities.AddArea("Wall area").Value = 156; floors.Quantities.AddArea("Floor area").Value = 466; windows.Quantities.AddCount("Windows count").Value = 45; txn.Commit(); } Assert.IsTrue(model.IsValid(out IEnumerable <ValidationResult> errs)); model.SaveAsIfc("orf.ifc"); } }