public Ifc4.IfcPropertySet GetIfcPropertySetFromRelatingPropertyDefinition() { Ifc4.Document document = this.Document; //<IfcRelDefinesByProperties id="i98" GlobalId="0DZQ9OC1z3EwnCxq2V5i7q" Name="PropertyContainer" Description="BuildingContainerForPropertySet"> // <RelatedObjects xsi:type="IfcBuilding" ref="i85"/> // <RelatingPropertyDefinition> // <IfcPropertySet xsi:nil="true" ref="i97"/> // </RelatingPropertyDefinition> //</IfcRelDefinesByProperties> IfcPropertySet ifcPropertySet = (from ifcRelDefinesByProperties in document.IfcXmlDocument.Items.OfType <Ifc4.IfcRelDefinesByProperties>() where ifcRelDefinesByProperties.RelatedObjects != null && ifcRelDefinesByProperties.RelatedObjects.Ref == this.Id && ifcRelDefinesByProperties.RelatingPropertyDefinition != null && ifcRelDefinesByProperties.RelatingPropertyDefinition.Item is IfcPropertySet select ifcRelDefinesByProperties.RelatingPropertyDefinition.Item).FirstOrDefault() as IfcPropertySet; if (ifcPropertySet != null && ifcPropertySet.IsRef) { ifcPropertySet = document.IfcXmlDocument.Items.OfType <IfcPropertySet>().FirstOrDefault(item => item.Id == ifcPropertySet.Ref); } return(ifcPropertySet); }
//void IBindingList.AddIndex(PropertyDescriptor property) //{ // throw new NotImplementedException(); //} public virtual object AddNew() { // darf auch keine base Funktionalität geben!!! //throw new NotImplementedException(); T instance = Activator.CreateInstance <T>() as T; ((Ifc4.Interfaces.IBaseObjects <T>) this).Add(instance); instance.Parent = this; Ifc4.Document document = this.GetParent <Ifc4.Document>(); if (document != null) { Entity entity = instance as Entity; if (entity != null) { entity.Id = document.GetNextSid(); document.IfcXmlDocument.Items.Add(entity); } IfcRoot ifcRoot = instance as IfcRoot; if (ifcRoot != null) { ifcRoot.GlobalId = document.GetNewGlobalId(); } return(instance); } return(null); }
private void button1_Click(object sender, EventArgs e) { string ifcFullName = @"C:\tmp\a.ifcxml"; Ifc4.Document document = Ifc4.Workspace.CurrentWorkspace.CreateDocument(ifcFullName, true); var header = document.IfcXmlDocument.Header; header.Organization = "My Organisation"; var ifcSite = document.Project.Sites.AddNewSite(); ifcSite.LongName = "A-Project"; var ifcBuilding = ifcSite.Buildings.AddNewBuilding(); ifcBuilding.LongName = "B-Building"; var ifcBuildingStorey = ifcBuilding.BuildingStoreys.AddNewBuildingStorey(); ifcBuildingStorey.LongName = "C-Storey"; var ifcSpace = ifcBuildingStorey.Spaces.AddNewSpace(); ifcSpace.LongName = "D-Room"; document.Workspace.SaveDocument(ifcFullName); }
/// <summary> /// Loading the ifc xml from file /// </summary> private void LoadXML() { if (File.Exists(m_filename)) { m_ifcDocument = Ifc4.Workspace.CurrentWorkspace.OpenDocument(m_filename); if (m_ifcDocument != null) { try { _richTextBox.Text += m_ifcDocument.Project.Name + "\n"; if (m_ifcDocument.Project.Sites != null) { Ifc4.IfcSite site = m_ifcDocument.Project.Sites.First(); _richTextBox.Text += site.LongName + "\n"; foreach (Ifc4.IfcBuilding bldg in site.Buildings) { _richTextBox.Text += bldg.LongName + "\n"; foreach (Ifc4.IfcBuildingStorey storey in bldg.BuildingStoreys) { _richTextBox.Text += storey.LongName + "\n"; } } } } catch (Exception ex) { } } } }
static void Main(string[] args) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Ifc xml files (*.ifcxml)|*.ifcxml|All files (*.*)|*.*"; dlg.InitialDirectory = Path.GetDirectoryName(typeof(SampleIfcReader.Program).Assembly.Location); dlg.CheckFileExists = true; dlg.Multiselect = false; if (dlg.ShowDialog() == DialogResult.OK) { Ifc4.Document ifcDocument = Ifc4.Workspace.CurrentWorkspace.OpenDocument(dlg.FileName); var header = ifcDocument.IfcXmlDocument.Header; header.Organization = "My Organisation"; var ifcSite = ifcDocument.Project.Sites.AddNewSite(); ifcSite.LongName = "Site"; var ifcBuilding = ifcSite.Buildings.AddNewBuilding(); ifcBuilding.LongName = "Building"; var ifcBuildingStorey = ifcBuilding.BuildingStoreys.AddNewBuildingStorey(); ifcBuildingStorey.LongName = "Storey"; var ifcSpace = ifcBuildingStorey.Spaces.AddNewSpace(); ifcSpace.LongName = "Room"; ifcDocument.Workspace.SaveDocument(dlg.FileName); } }
private void DeleteIfcRelAssociatesClassification() { Ifc4.Document document = this.Document; foreach (var ifcRelAssociatesClassification in GetIfcRelAssociatesClassificationCollection().ToList()) { document.IfcXmlDocument.Items.Remove(ifcRelAssociatesClassification); } }
private IEnumerable <IfcExternalReferenceRelationship> GetIfcExternalReferenceRelationshipCollection(IfcClassificationReference ifcClassificationReference) { Ifc4.Document document = this.Document; return(from ifcExternalReferenceRelationship in document.IfcXmlDocument.Items.OfType <Ifc4.IfcExternalReferenceRelationship>() where ifcExternalReferenceRelationship.RelatingReference != null && ifcExternalReferenceRelationship.RelatingReference.Ref == ifcClassificationReference.Id select ifcExternalReferenceRelationship); }
private IEnumerable <IfcRelAssociatesClassification> GetIfcRelAssociatesClassificationCollection() { Ifc4.Document document = this.Document; return(from ifcRelAssociatesClassification in document.IfcXmlDocument.Items.OfType <Ifc4.IfcRelAssociatesClassification>() where ifcRelAssociatesClassification.RelatedObjects != null && ifcRelAssociatesClassification.RelatedObjects.Items.Count == 1 && ifcRelAssociatesClassification.RelatedObjects.Items[0].Ref == this.Id select ifcRelAssociatesClassification); }
public bool SerializeTest(string ifcFullName) { if (String.IsNullOrEmpty(ifcFullName)) { throw new ArgumentNullException("ifcFullName", "SerializeTest()"); return(false); } System.IO.FileInfo fileInfo = new System.IO.FileInfo(ifcFullName); if (!fileInfo.Exists) { RaiseMessageLogged(String.Format("{0} - File '{0}' not found!", "SerializeTest()", ifcFullName)); return(false); } try { string f0_Org = fileInfo.FullName; string f0 = System.IO.Path.ChangeExtension(f0_Org, ".tmp" + fileInfo.Extension); // bool validate = this.Validate(f0_Org); System.IO.File.Copy(f0_Org, f0, true); Ifc4.Document document = Ifc4.Workspace.CurrentWorkspace.OpenDocument(f0); Ifc4.IfcXML ifcXML = document.IfcXmlDocument; document.SaveAs(f0 + ".0", new SaveOptions()); //Correction(f0 + ".0"); //validate = this.Validate(f0 + ".0"); RaiseMessageLogged(String.Format("Serialized file '{0}'", f0 + ".0")); RaiseMessageLogged("End"); return(true); } catch (Exception exc) { System.Diagnostics.Debug.WriteLine(exc.Message); Exception innerException = exc.InnerException; while (innerException != null) { RaiseMessageLogged(innerException.Message); innerException = innerException.InnerException; } return(false); } }
private Ifc4.IfcClassificationReference GetIfcClassificationReferenceFromIfcExternalReferenceRelationship() { Ifc4.Document document = this.Document; IfcClassificationReference ifcClassificationReference = (from ifcExternalReferenceRelationship in document.IfcXmlDocument.Items.OfType <Ifc4.IfcExternalReferenceRelationship>() where ifcExternalReferenceRelationship.RelatedResourceObjects != null && ifcExternalReferenceRelationship.RelatedResourceObjects.Items.Exists(item => item.Ref == this.Id) && ifcExternalReferenceRelationship.RelatingReference is IfcClassificationReference select ifcExternalReferenceRelationship.RelatingReference).FirstOrDefault() as IfcClassificationReference; if (ifcClassificationReference != null && ifcClassificationReference.IsRef) { ifcClassificationReference = this.Document.IfcXmlDocument.Items.OfType <IfcClassificationReference>().FirstOrDefault(item => item.Id == ifcClassificationReference.Ref); } return(ifcClassificationReference); }
static void Main(string[] args) { OpenFileDialog dlgFile = new OpenFileDialog(); dlgFile.Filter = "Ifc xml files (*.ifcxml)|*.ifcxml|All files (*.*)|*.*"; dlgFile.InitialDirectory = Path.GetDirectoryName(typeof(SampleIfcReader.Program).Assembly.Location); dlgFile.CheckFileExists = true; dlgFile.Multiselect = false; dlgFile.Title = "Select the file, you want to open..."; FolderBrowserDialog dlgNewFolder = new FolderBrowserDialog(); dlgNewFolder.Description = "Select the target folder, for your file"; if (dlgFile.ShowDialog() == DialogResult.OK) { Ifc4.Document ifcDocument = Ifc4.Workspace.CurrentWorkspace.OpenDocument(dlgFile.FileName); string targetFolder = string.Empty; if (dlgNewFolder.ShowDialog() == DialogResult.OK) { targetFolder = dlgNewFolder.SelectedPath; } var header = ifcDocument.IfcXmlDocument.Header; header.Organization = "My Organisation"; header.Documentation = "https://github.com/CAFM-Connect/Ifc.NET"; var ifcSite = ifcDocument.Project.Sites.AddNewSite(); ifcSite.LongName = "Site"; var ifcBuilding = ifcSite.Buildings.AddNewBuilding(); ifcBuilding.LongName = "Building"; var ifcBuildingStorey = ifcBuilding.BuildingStoreys.AddNewBuildingStorey(); ifcBuildingStorey.LongName = "Storey"; var ifcSpace = ifcBuildingStorey.Spaces.AddNewSpace(); ifcSpace.LongName = "Room"; ifcDocument.Workspace.SaveDocument(dlgFile.FileName); Console.WriteLine(string.Format("New file saved as {0}", Path.Combine(targetFolder, Path.GetFileName(dlgFile.FileName)))); Console.ReadLine(); } }
private Ifc4.IfcClassificationReference GetIfcClassificationReferenceFromIfcRelAssociatesClassification() { Ifc4.Document document = this.Document; IfcClassificationReference ifcClassificationReference = (from ifcRelAssociatesClassification in document.IfcXmlDocument.Items.OfType <Ifc4.IfcRelAssociatesClassification>() where ifcRelAssociatesClassification.RelatedObjects != null && ifcRelAssociatesClassification.RelatedObjects.Items.Exists(item => item.Ref == this.Id) && ifcRelAssociatesClassification.RelatingClassification != null && ifcRelAssociatesClassification.RelatingClassification.Item is IfcClassificationReference select ifcRelAssociatesClassification.RelatingClassification.Item).FirstOrDefault() as IfcClassificationReference; if (ifcClassificationReference != null && ifcClassificationReference.IsRef) { ifcClassificationReference = this.Document.IfcXmlDocument.Items.OfType <IfcClassificationReference>().FirstOrDefault(item => item.Id == ifcClassificationReference.Ref); } return(ifcClassificationReference); }
private static IfcDerivedUnit AddIfcDerivedUnit( Ifc4.Document document, Unit unit, IfcDerivedUnit ifcDerivedUnit ) { if (document.Project.UnitsInContext == null) document.Project.UnitsInContext = new IfcUnitAssignment(); var ifcUnitAssignment = document.Project.UnitsInContext; if (ifcUnitAssignment.Units == null) ifcUnitAssignment.Units = new IfcUnitAssignmentUnits(); var ifcUnitAssignmentUnits = ifcUnitAssignment.Units; ifcUnitAssignmentUnits.Items.Add(ifcDerivedUnit); return ifcDerivedUnit; }
public Ifc4.IfcElementQuantity GetIfcElementQuantityFromRelatingPropertyDefinition() { Ifc4.Document document = this.Document; m_IfcElementQuantities = null; IfcElementQuantity ifcElementQuantity = (from ifcRelDefinesByProperties in document.IfcXmlDocument.Items.OfType <Ifc4.IfcRelDefinesByProperties>() where ifcRelDefinesByProperties.RelatedObjects != null && ifcRelDefinesByProperties.RelatedObjects.Ref == this.Id && ifcRelDefinesByProperties.RelatingPropertyDefinition != null && ifcRelDefinesByProperties.RelatingPropertyDefinition.Item is IfcElementQuantity select ifcRelDefinesByProperties.RelatingPropertyDefinition.Item).FirstOrDefault() as IfcElementQuantity; if (ifcElementQuantity != null && ifcElementQuantity.IsRef) { ifcElementQuantity = document.IfcXmlDocument.Items.OfType <IfcElementQuantity>().FirstOrDefault(item => item.Id == ifcElementQuantity.Ref); } return(ifcElementQuantity); }
private static IfcSIUnit AddIfcSIUnit( Ifc4.Document document, Unit unit, IfcUnitEnum? ifcUnitEnum, IfcSIPrefix? ifcSIPrefix, IfcSIUnitName? ifcSIUnitName ) { if (document.Project.UnitsInContext == null) document.Project.UnitsInContext = new IfcUnitAssignment(); var ifcUnitAssignment = document.Project.UnitsInContext; if (ifcUnitAssignment.Units == null) ifcUnitAssignment.Units = new IfcUnitAssignmentUnits(); var ifcUnitAssignmentUnits = ifcUnitAssignment.Units; IfcSIUnit ifcSIUnit = new IfcSIUnit() { Id = document.GetNextSid(), }; if (ifcUnitEnum.HasValue) { ifcSIUnit.UnitType = ifcUnitEnum.Value; ifcSIUnit.UnitTypeSpecified = true; } if (ifcSIPrefix.HasValue) { ifcSIUnit.Prefix = ifcSIPrefix.Value; ifcSIUnit.PrefixSpecified = true; } if (ifcSIUnitName.HasValue) { ifcSIUnit.Name = ifcSIUnitName.Value; ifcSIUnit.NameSpecified = true; } ifcUnitAssignmentUnits.Items.Add(ifcSIUnit); return ifcSIUnit; }
public void AddRelatedObject <T>(T t) where T : IfcRoot { if (t == null) { return; } Ifc4.Document document = this.Document; var ifcRelAssociatesDocumentCollection = (from ifcRelAssociatesDocument in document.IfcXmlDocument.Items.OfType <Ifc4.IfcRelAssociatesDocument>() where ifcRelAssociatesDocument.RelatingDocument?.Item?.Ref == this.Id select ifcRelAssociatesDocument).ToList(); if (ifcRelAssociatesDocumentCollection.Any()) { // IfcRelAssociatesDocument already exists foreach (var ifcRelAssociatesDocument in ifcRelAssociatesDocumentCollection) { // add related object if not exists if ( ifcRelAssociatesDocument.RelatedObjects != null && !ifcRelAssociatesDocument.RelatedObjects.Items.Exists(item => item.Ref == t.Id) ) { ifcRelAssociatesDocument.RelatedObjects.Items.Add(t.RefInstance <T>()); } } } else { // add new IfcRelAssociatesDocument IfcRelAssociatesDocument ifcRelAssociatesDocument = new IfcRelAssociatesDocument() { GlobalId = Document.GetNewGlobalId(), RelatingDocument = new IfcRelAssociatesDocumentRelatingDocument() { Item = this.RefInstance <IfcDocumentInformation>() } }; ifcRelAssociatesDocument.RelatedObjects = new IfcRelAssociatesRelatedObjects(); ifcRelAssociatesDocument.RelatedObjects.Items.Add(t.RefInstance <T>()); this.Document.IfcXmlDocument.Items.Add(ifcRelAssociatesDocument); } }
private void DeleteIfcExternalReferenceRelationship() { Ifc4.Document document = this.Document; List <IfcExternalReferenceRelationship> removeIfcExternalReferenceRelationshipCollection = new List <IfcExternalReferenceRelationship>(); foreach (var ifcExternalReferenceRelationship in document.IfcXmlDocument.Items.OfType <Ifc4.IfcExternalReferenceRelationship>()) { if (ifcExternalReferenceRelationship.RelatedResourceObjects != null) { ifcExternalReferenceRelationship.RelatedResourceObjects.Items.RemoveAll(item => item.Ref == this.Id); if (!ifcExternalReferenceRelationship.RelatedResourceObjects.Items.Any()) { removeIfcExternalReferenceRelationshipCollection.Add(ifcExternalReferenceRelationship); } } } foreach (var ifcExternalReferenceRelationship in removeIfcExternalReferenceRelationshipCollection) { document.IfcXmlDocument.Items.Remove(ifcExternalReferenceRelationship); } }
internal Entity AddUnitToIfcDocument(Ifc4.Document document, Ifc4.Unit unit) { if (document == null) throw new ArgumentNullException("AddUnitToIfcDocument(Ifc4.Document document, ...)"); if (unit == null) throw new ArgumentNullException("AddUnitToIfcDocument(..., Unit unit)"); Entity entity = null; if (unit.Key == "m") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Lengthunit, null, IfcSIUnitName.Metre); } else if (unit.Key == "dm") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Lengthunit, IfcSIPrefix.Deci, IfcSIUnitName.Metre); } else if (unit.Key == "cm") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Lengthunit, IfcSIPrefix.Centi, IfcSIUnitName.Metre); } else if (unit.Key == "mm") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Lengthunit, IfcSIPrefix.Milli, IfcSIUnitName.Metre); } else if (unit.Key == "m²") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Areaunit, null, IfcSIUnitName.SquareMetre); } else if (unit.Key == "dm²") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Areaunit, IfcSIPrefix.Deci, IfcSIUnitName.SquareMetre); } else if (unit.Key == "cm²") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Areaunit, IfcSIPrefix.Centi, IfcSIUnitName.SquareMetre); } else if (unit.Key == "mm²") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Areaunit, IfcSIPrefix.Milli, IfcSIUnitName.SquareMetre); } else if (unit.Key == "m³") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Volumeunit, null, IfcSIUnitName.CubicMetre); } else if (unit.Key == "dm³") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Volumeunit, IfcSIPrefix.Deci, IfcSIUnitName.CubicMetre); } else if (unit.Key == "cm³") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Volumeunit, IfcSIPrefix.Centi, IfcSIUnitName.CubicMetre); } else if (unit.Key == "mm³") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Volumeunit, IfcSIPrefix.Milli, IfcSIUnitName.CubicMetre); } // 1Liter = 1dm³ // 1m³ = 1000dm³ else if (unit.Key == "l" || unit.Key == "Liter") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Volumeunit, IfcSIPrefix.Deci, IfcSIUnitName.CubicMetre); } else if (unit.Key == "V") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Electricvoltageunit, null, IfcSIUnitName.Volt); } else if (unit.Key == "J") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Energyunit, null, IfcSIUnitName.Joule); } else if (unit.Key == "°C") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Thermodynamictemperatureunit, null, IfcSIUnitName.DegreeCelsius); } else if (unit.Key == "A") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Electriccurrentunit, null, IfcSIUnitName.Ampere); } else if (unit.Key == "Hz") // 1/s { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Frequencyunit, null, IfcSIUnitName.Hertz); } else if (unit.Key == "N") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Forceunit, null, IfcSIUnitName.Newton); } else if (unit.Key == "kg") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Massunit, IfcSIPrefix.Kilo, IfcSIUnitName.Gram); } else if (unit.Key == "g") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Massunit, null, IfcSIUnitName.Gram); } else if (unit.Key == "s") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Timeunit, null, IfcSIUnitName.Second); } else if (unit.Key == "m/s") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Linearvelocityunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true, } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true, } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } else if (unit.Key == "m/s²") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Accelerationunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true, } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -2, ExponentSpecified = true, Unit = new IfcSIUnit { UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true, } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } else if (unit.Key == "m³/h") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Volumetricflowrateunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 3, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -1, ExponentSpecified = true, Unit = new IfcConversionBasedUnit { Name = "Hour", UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true, ConversionFactor = new IfcMeasureWithUnit() { ValueComponent = new IfcMeasureWithUnitValueComponent() { Item = new IfcTimeMeasurewrapper() { Value = 3600.0 } }, UnitComponent = new IfcMeasureWithUnitUnitComponent() { Item = new IfcSIUnit() { UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true } } } } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } else if (unit.Key == "Ah") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Heatfluxdensityunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Electriccurrentunit, UnitTypeSpecified = true } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -1, ExponentSpecified = true, Unit = new IfcConversionBasedUnit { Name = "Hour", UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true, ConversionFactor = new IfcMeasureWithUnit() { ValueComponent = new IfcMeasureWithUnitValueComponent() { Item = new IfcTimeMeasurewrapper() { Value = 3600.0 } }, UnitComponent = new IfcMeasureWithUnitUnitComponent() { Item = new IfcSIUnit() { UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true } } } } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } else if (unit.Key == "Ohm") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Electricresistanceunit, null, IfcSIUnitName.Ohm); } else if (unit.Key == "kg/m³") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Massdensityunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Massunit, UnitTypeSpecified = true, } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -3, ExponentSpecified = true, Unit = new IfcSIUnit { UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true, } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } else if (unit.Key == "N/m²") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Planarforceunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Forceunit, UnitTypeSpecified = true, } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -2, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true, } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } else if (unit.Key == "W/m²") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Heatfluxdensityunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Powerunit, UnitTypeSpecified = true, } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -2, ExponentSpecified = true, Unit = new IfcSIUnit { UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true, } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } else if (unit.Key == "W") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Powerunit, null, IfcSIUnitName.Watt); } else if (unit.Key == "kW") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Powerunit, IfcSIPrefix.Kilo, IfcSIUnitName.Watt); } else if (unit.Key == "Pa") { entity = AddIfcSIUnit(document, unit, IfcUnitEnum.Pressureunit, null, IfcSIUnitName.Pascal); } else if (unit.Key == "db") { IfcDerivedUnit ifcDerivedUnit = new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Soundpowerlevelunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() }; ifcDerivedUnit.Elements.IfcDerivedUnitElement.AddRange( new IfcDerivedUnitElement[] { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, ExponentSpecified = true, Unit = new IfcSIUnit() { UnitType = IfcUnitEnum.Powerunit, UnitTypeSpecified = true, } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -1, ExponentSpecified = true, Unit = new IfcSIUnit { UnitType = IfcUnitEnum.Powerunit, UnitTypeSpecified = true, } } } ); entity = AddIfcDerivedUnit(document, unit, ifcDerivedUnit); } if (entity == null) throw new NullReferenceException("AddUnitToIfcDocument - Entity = null"); return entity; }
public bool CreateTestIfc(string ifcFullName) { Ifc4.Document document = Ifc4.Workspace.CurrentWorkspace.CreateDocument(ifcFullName, true); document.MessageLogged += document_MessageLogged; if (String.IsNullOrEmpty(ifcFullName)) { throw new ArgumentNullException("ifcFullName", "CreateTestIfc()"); return(false); } try { System.IO.File.Delete(ifcFullName); } catch { } //ifcXml.express = new string[] { }; //ifcXml.configuration = new string[] { }; document.IfcXmlDocument.Id = "ifcXML4"; document.IfcXmlDocument.Header = new UosHeader() { //<time_stamp>2013-04-17T14:34:08.5257209+02:00</time_stamp> Name = System.IO.Path.GetFileNameWithoutExtension(ifcFullName), // time_stamp = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss", System.Globalization.CultureInfo.InvariantCulture), TimeStamp = DateTime.Now, Author = System.Environment.UserName, Organization = "eTASK Service-Management GmbH", PreprocessorVersion = ".NET API etask.ifc", OriginatingSystem = ".NET API etask.ifc", Authorization = "file created with .NET API etask.ifc", Documentation = "ViewDefinition [notYetAssigned]" // version }; document.Project.UnitsInContext = new IfcUnitAssignment() { Units = new IfcUnitAssignmentUnits() { Items = new List <Entity>() { new IfcSIUnit() { Id = document.GetNextSid(), Prefix = IfcSIPrefix.Milli, Name = IfcSIUnitName.Metre, NameSpecified = true, UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true }, new IfcDerivedUnit() { Elements = new IfcDerivedUnitElements() { IfcDerivedUnitElement = new List <IfcDerivedUnitElement>() { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 1, Unit = new IfcSIUnit() { Name = IfcSIUnitName.Metre, NameSpecified = true, UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true } }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -1, Unit = new IfcSIUnit() { Name = IfcSIUnitName.Second, NameSpecified = true, UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true } } } } }, new IfcDerivedUnit() { Id = document.GetNextSid(), UnitType = IfcDerivedUnitEnum.Volumetricflowrateunit, UnitTypeSpecified = true, Elements = new IfcDerivedUnitElements() { IfcDerivedUnitElement = new List <IfcDerivedUnitElement>() { new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = 3, ExponentSpecified = true, Unit = new IfcSIUnit() { Name = IfcSIUnitName.Metre, NameSpecified = true, UnitType = IfcUnitEnum.Lengthunit, UnitTypeSpecified = true }, }, new IfcDerivedUnitElement() { Id = document.GetNextSid(), Exponent = -1, ExponentSpecified = true, //Name = IfcSIUnitName.second, //NameSpecified = true, //UnitType = IfcUnitEnum.timeunit, //UnitTypeSpecified = true, Unit = new IfcConversionBasedUnit() { ConversionFactor = new IfcMeasureWithUnit() { ValueComponent = new IfcMeasureWithUnitValueComponent() { Item = new IfcTimeMeasurewrapper() { Value = 3600.0 } }, UnitComponent = new IfcMeasureWithUnitUnitComponent() { Item = new IfcSIUnit() { Name = IfcSIUnitName.Second, NameSpecified = true, UnitType = IfcUnitEnum.Timeunit, UnitTypeSpecified = true } } } } } } } } } } }; Ifc4.IfcClassification ifcClassification = document.AddNew <IfcClassification>(); //ifcClassification.id = document.GetNextSid(); ifcClassification.Edition = "Version 1.06"; ifcClassification.EditionDate = "2014-08-14T09:39:57"; ifcClassification.Name = "CAFM-Connect Katalog 2014"; Ifc4.IfcRelAssociatesClassification ifcRelAssociatesClassification = document.AddNew <IfcRelAssociatesClassification>(); //ifcRelAssociatesClassification.id = document.GetNextSid(); ifcRelAssociatesClassification.GlobalId = "1XiFKGEHP6PxQPxDU2E3PA"; ifcRelAssociatesClassification.Name = "CAFM-Connect Katalog 2014 zu IfcClassification"; ifcRelAssociatesClassification.RelatedObjects = new IfcRelAssociatesRelatedObjects() { Items = new List <IfcRoot>() { new Ifc4.IfcProject() { @Ref = document.Project.Id } } }; ifcRelAssociatesClassification.RelatingClassification = new IfcRelAssociatesClassificationRelatingClassification() { Item = new IfcClassification() { @Ref = ifcClassification.Id } }; //<IfcClassification id="i120" Edition="Version 1.06" EditionDate="2014-08-14T09:39:57" Name="CAFM-Connect Katalog 2014" /> //<IfcRelAssociatesClassification id="i121" GlobalId="1XiFKGEHP6PxQPxDU2E3PA" Name="CAFM-Connect Katalog 2014 zu IfcClassification"> // <RelatedObjects> // <IfcProject ref="i100" xsi:nil="true" /> // </RelatedObjects> // <RelatingClassification> // <IfcClassification ref="i120" xsi:nil="true" /> // </RelatingClassification> //</IfcRelAssociatesClassification> try { document.Save(new SaveOptions()); document.Close(); string message; document.Open(ifcFullName, out message); document.SaveAs(ifcFullName + ".0", new SaveOptions()); RaiseMessageLogged(this, System.IO.File.ReadAllText(document.FullName)); return(true); } catch (Exception exc) { System.Diagnostics.Debug.WriteLine(exc.Message); Exception innerException = exc.InnerException; while (innerException != null) { RaiseMessageLogged(innerException.Message); innerException = innerException.InnerException; } return(false); } }
public T AddNewFacility(CcFacility cloneFacility = null, bool oneToOneCopy = false) { EventType enabledEventTypes = BaseObject.EventsEnabled; BaseObject.EventsEnabled = EventType.None; try { T facility = (T)AddNew(); // ------------------------------------------------------------------------------ // Annahme Anlage = IfcBuildingElementProxy IfcBuildingElementProxy ifcBuildingElementProxy = new IfcBuildingElementProxy(); facility.IfcObjectDefinition = ifcBuildingElementProxy; ifcBuildingElementProxy.Parent = this; Ifc4.Document document = this.GetParent <Ifc4.Document>(); if (document != null) { Entity entity = ifcBuildingElementProxy as Entity; if (entity != null) { entity.Id = document.GetNextSid(); document.IfcXmlDocument.Items.Add(entity); } IfcRoot ifcRoot = ifcBuildingElementProxy as IfcRoot; if (ifcRoot != null) { ifcRoot.GlobalId = document.GetNewGlobalId(); } } // ------------------------------------------------------------------------------ if (this.Parent.GetType() == typeof(Ifc4.IfcProject)) { IEnumerable <IfcRelAggregates> ifcRelAggregatesCollection = this.Document.IfcXmlDocument.Items.OfType <IfcRelAggregates>() .Where(item => item.RelatingObject != null && item.RelatingObject.Ref == ((Ifc4.IfcProject) this.Parent).Id).ToList(); if (ifcRelAggregatesCollection.Any()) { foreach (IfcRelAggregates ifcRelAggregates in ifcRelAggregatesCollection) { var relatedObject = ifcRelAggregates.RelatedObjects.Items.FirstOrDefault(item => item.Ref == ifcBuildingElementProxy.Id); if (relatedObject == null) { ifcRelAggregates.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance()); } } } else { IfcRelAggregates relAggregatesProject = new IfcRelAggregates() { GlobalId = Document.GetNewGlobalId(), // kann aktuell nur IfcProject sein RelatingObject = new Ifc4.IfcProject() { Ref = ((Ifc4.IfcProject) this.Parent).Id } }; relAggregatesProject.RelatedObjects = new IfcRelAggregatesRelatedObjects(); relAggregatesProject.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance()); this.Document.IfcXmlDocument.Items.Add(relAggregatesProject); } } // ------------------------------------------------------------------------------ if (this.Parent.GetType() == typeof(Ifc4.CcFacility)) { if (((Ifc4.CcFacility) this.Parent).IfcObjectDefinition != null) { Ifc4.IfcRelAggregates ifcRelAggregates = ((Ifc4.CcFacility) this.Parent).GetIfcRelAggregates(); ifcRelAggregates.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance()); } else if (((Ifc4.CcFacility) this.Parent).IfcSystem != null) { Ifc4.IfcRelAssignsToGroup ifcRelAssignsToGroup = ((Ifc4.CcFacility) this.Parent).GetIfcRelAssignsToGroup(); ifcRelAssignsToGroup.RelatedObjects.Items.Add(ifcBuildingElementProxy.RefInstance()); } } // ------------------------------------------------------------------------------ // assign facility properties from clipboard facility facility.AssignPropertiesFromFacility(cloneFacility, oneToOneCopy); // ------------------------------------------------------------------------------ return(facility); } catch (Exception exc) { return(default(T)); } finally { BaseObject.EventsEnabled = enabledEventTypes; } }
private List <CustomModel.CustomPropertyDescriptor> GetRuntimeProperties(Ifc4.BaseObject baseObject) { CustomModel.CustomPropertyDescriptor cpd; CustomModel.CustomProperty customProperty; List <CustomModel.CustomPropertyDescriptor> propertyDescriptorCollection = new List <CustomModel.CustomPropertyDescriptor>(); Ifc4.CcFacility facility = baseObject as Ifc4.CcFacility; if (facility == null || String.IsNullOrEmpty(facility.ObjectTypeId)) { return(propertyDescriptorCollection); } Ifc4.Document document = baseObject.GetParent <Ifc4.Document>(); IEnumerable <Ifc4.IfcPropertySetTemplate> ifcPropertySetTemplateCollection = document.GetIfcPropertySetTemplateCollection(facility); ////string objectTypeId = null; ////if (facility != null && !String.IsNullOrEmpty(facility.ObjectTypeId)) ////{ //// objectTypeId = facility.ObjectTypeId; //// IEnumerable<Ifc4.IfcRelAssociatesClassification> ifcRelAssociatesClassificationCollection = document.IfcXmlDocument.Items.OfType<Ifc4.IfcRelAssociatesClassification>(); //// IEnumerable<string> relatedObjectsRefs = from ifcRelAssociatesClassification in ifcRelAssociatesClassificationCollection //// from relatedObject in ifcRelAssociatesClassification.RelatedObjects.Items //// where ifcRelAssociatesClassification.RelatingClassification.Item != null && ifcRelAssociatesClassification.RelatingClassification.Item.Ref == objectTypeId //// select relatedObject.Ref; //// ifcPropertySetTemplateCollection = document.IfcXmlDocument.Items.OfType<Ifc4.IfcPropertySetTemplate>().Where(item => relatedObjectsRefs.Contains(item.Id)); ////} if (ifcPropertySetTemplateCollection == null) { return(propertyDescriptorCollection); } foreach (var ifcPropertySetTemplate in ifcPropertySetTemplateCollection) { foreach (var propertyTemplate in ifcPropertySetTemplate.HasPropertyTemplates.Items) { Ifc4.IfcSimplePropertyTemplate simplePropertyTemplate = propertyTemplate as Ifc4.IfcSimplePropertyTemplate; if (simplePropertyTemplate == null) { continue; } //string displayName = String.IsNullOrEmpty(simplePropertyTemplate.PrimaryMeasureType) ? simplePropertyTemplate.Name : String.Format("{0} [{1}]", simplePropertyTemplate.Name, simplePropertyTemplate.PrimaryMeasureType); string displayName = simplePropertyTemplate.Name; string unit = null; if (simplePropertyTemplate.PrimaryUnit != null) { if (simplePropertyTemplate.PrimaryUnit.Item is Ifc4.IfcSIUnit) { Ifc4.IfcSIUnit ifcSIUnit = GetUnit((Ifc4.IfcSIUnit)simplePropertyTemplate.PrimaryUnit.Item); if (ifcSIUnit.NameSpecified) { if (ifcSIUnit.PrefixSpecified) { if (ifcSIUnit.Prefix == IfcSIPrefix.Centi && ifcSIUnit.Name == IfcSIUnitName.Metre) { unit = "[cm]"; } else if (ifcSIUnit.Prefix == IfcSIPrefix.Milli && ifcSIUnit.Name == IfcSIUnitName.Metre) { unit = "[mm]"; } else if (ifcSIUnit.Prefix == IfcSIPrefix.Kilo && ifcSIUnit.Name == IfcSIUnitName.Gram) { unit = "[kg]"; } else if (ifcSIUnit.Prefix == IfcSIPrefix.Kilo && ifcSIUnit.Name == IfcSIUnitName.Watt) { unit = "[kW]"; } } else { if (ifcSIUnit.Name == IfcSIUnitName.Metre) { unit = "[m]"; } else if (ifcSIUnit.Name == IfcSIUnitName.SquareMetre) { unit = "[m²]"; } else if (ifcSIUnit.Name == IfcSIUnitName.CubicMetre) { unit = "[m³]"; } else if (ifcSIUnit.Name == IfcSIUnitName.Volt) { unit = "[V]"; } else if (ifcSIUnit.Name == IfcSIUnitName.DegreeCelsius) { unit = "[°C]"; } else if (ifcSIUnit.Name == IfcSIUnitName.Ampere) { unit = "[A]"; } else if (ifcSIUnit.Name == IfcSIUnitName.Hertz) { unit = "[Hz]"; } else if (ifcSIUnit.Name == IfcSIUnitName.Watt) { unit = "[W]"; } else if (ifcSIUnit.Name == IfcSIUnitName.Pascal) { unit = "[Pa]"; } } } } else if (simplePropertyTemplate.PrimaryUnit.Item is Ifc4.IfcDerivedUnit) { Ifc4.IfcDerivedUnit ifcDerivedUnit = GetUnit <Ifc4.IfcDerivedUnit>((Ifc4.IfcDerivedUnit)simplePropertyTemplate.PrimaryUnit.Item); if (ifcDerivedUnit.UnitTypeSpecified) { if (ifcDerivedUnit.UnitType == IfcDerivedUnitEnum.Heatfluxdensityunit) { unit = "[Ah]"; } else if (ifcDerivedUnit.UnitType == IfcDerivedUnitEnum.Volumetricflowrateunit) { unit = "[m³/h]"; } else if (ifcDerivedUnit.UnitType == IfcDerivedUnitEnum.Massdensityunit) { unit = "[kg/m³]"; } else if (ifcDerivedUnit.UnitType == IfcDerivedUnitEnum.Soundpowerlevelunit) { unit = "[db]"; } } } if (!String.IsNullOrEmpty(unit)) { displayName = String.Concat(displayName, " ", unit); } } List <Attribute> attributes = new List <Attribute>() { new System.ComponentModel.BrowsableAttribute(true), new System.ComponentModel.CategoryAttribute("Runtime Object"), new System.ComponentModel.DisplayNameAttribute(displayName) }; CustomPropertyStandardValues customPropertyStandardValues = null; Type customPropertyType; string primaryMeasureType = simplePropertyTemplate.PrimaryMeasureType; if (simplePropertyTemplate.TemplateType == Ifc4.IfcSimplePropertyTemplateTypeEnum.PSinglevalue) { // default customPropertyType = typeof(System.String); // overwrite if (!String.IsNullOrEmpty(primaryMeasureType)) { if (primaryMeasureType.Equals("IfcText", StringComparison.OrdinalIgnoreCase)) { customPropertyType = typeof(System.String); } else if (primaryMeasureType.Equals("IfcDate", StringComparison.OrdinalIgnoreCase)) { customPropertyType = typeof(System.Nullable <DateTime>); attributes.Add(new System.ComponentModel.TypeConverterAttribute(typeof(CustomNullableTypeConverter <DateTime?>))); } else if (primaryMeasureType.Equals("IfcReal", StringComparison.OrdinalIgnoreCase)) { customPropertyType = typeof(System.Nullable <double>); attributes.Add(new System.ComponentModel.TypeConverterAttribute(typeof(CustomNullableTypeConverter <double?>))); } else if (primaryMeasureType.Equals("IfcBoolean", StringComparison.OrdinalIgnoreCase)) { customPropertyType = typeof(System.String); attributes.Add(new System.ComponentModel.TypeConverterAttribute(typeof(CustomBooleanNullableTypeConverter))); } } } else if (simplePropertyTemplate.TemplateType == Ifc4.IfcSimplePropertyTemplateTypeEnum.PEnumeratedvalue) { customPropertyStandardValues = new CustomPropertyStandardValues(); attributes.Add(new System.ComponentModel.TypeConverterAttribute(typeof(CustomEnumTypeConverter))); int i = 0; // add empty enum value if (simplePropertyTemplate.Enumerators.EnumerationValues.Items.Any()) { // empty string not possible - use a string with length > 0 customPropertyStandardValues.Add(new CustomPropertyStandardValue("E" + (i++), " ")); } foreach (var enumItem in simplePropertyTemplate.Enumerators.EnumerationValues.Items) { string enumValue; if (enumItem is Ifc4.IfcLabelwrapper) { Ifc4.IfcLabelwrapper labelWrapper = enumItem as Ifc4.IfcLabelwrapper; enumValue = labelWrapper.Value; } else { enumValue = enumItem.ToString(); } customPropertyStandardValues.Add(new CustomPropertyStandardValue("E" + (i++), enumValue.Trim())); } customPropertyType = typeof(System.Enum); } else { customPropertyType = typeof(System.String); } // ------------------------------------------------------------------ StringBuilder sbAttributeDescription = new StringBuilder(); sbAttributeDescription.AppendLine(""); if (String.IsNullOrEmpty(primaryMeasureType)) { sbAttributeDescription.AppendLine(String.Format("IFC4 Type: {0}", "unknown")); } else { sbAttributeDescription.AppendLine(String.Format("IFC4 Type: {0}", primaryMeasureType)); } if (customPropertyType.IsGenericType && customPropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { sbAttributeDescription.AppendLine(String.Format(".NET Type: Nullable {0}", (customPropertyType.GetGenericArguments()[0]).Name)); } else { sbAttributeDescription.AppendLine(String.Format(".NET Type: {0}", customPropertyType.Name)); } if (!String.IsNullOrEmpty(simplePropertyTemplate.Description)) { sbAttributeDescription.AppendLine(""); sbAttributeDescription.AppendLine(simplePropertyTemplate.Description); } if (sbAttributeDescription.Length > 0) { attributes.Add(new System.ComponentModel.DescriptionAttribute(sbAttributeDescription.ToString())); } // ------------------------------------------------------------------ customProperty = new CustomModel.CustomProperty ( null, simplePropertyTemplate.TempId.ToString("N"), simplePropertyTemplate.TempId.ToString("N"), customPropertyType, simplePropertyTemplate.Name, simplePropertyTemplate.Description, attributes, customPropertyStandardValues, null ); customProperty.IfcPropertyName = simplePropertyTemplate.Name; customProperty.IfcPropertyGlobalId = simplePropertyTemplate.GlobalId; CustomModel.CustomAssembly customAssembly = new CustomAssembly(); Type type = customAssembly.CreateDynamicEnum(customProperty); if (type != null) { customProperty.PropertyType = type; } cpd = new CustomModel.CustomPropertyDescriptor(customProperty, this); propertyDescriptorCollection.Add(cpd); } } return(propertyDescriptorCollection); }