public void UpdateModelViews(ModelViewSerializable mvs)
 {
     if (ModelViews == null)
     {
         ModelViews = new ObservableCollection <ModelViewSerializable>();
     }
     if ((mvs != null) && (SelectedEntity != null) && (CurrentDbContext != null))
     {
         if (mvs.RootEntityFullClassName == SelectedEntity.CodeElementFullName)
         {
             if (CurrentDbContext.ModelViews != null)
             {
                 ModelViewSerializable result =
                     CurrentDbContext.ModelViews.FirstOrDefault(m => m.ViewName == mvs.ViewName);
                 if (result != null)
                 {
                     if (!ModelViews.Any(m => m.ViewName == mvs.ViewName))
                     {
                         ModelViews.Add(mvs);
                     }
                 }
             }
         }
     }
     OnPropertyChanged("SelectedEntity");
 }
        public virtual void ImportBtnCommandAction(Object param)
        {
            OpenFileDialog ofdlg = new OpenFileDialog();

            ofdlg.Filter     = "JSON-files(*.json)|*.json";
            ofdlg.DefaultExt = "json";
            ofdlg.Title      = "Select a source to import";
            if (ofdlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                string jsonString = File.ReadAllText(ofdlg.FileName);
                DbContextSerializable srcContext = JsonConvert.DeserializeObject <DbContextSerializable>(jsonString);
                if (CurrentDbContext == null)
                {
                    return;
                }
                if (CurrentDbContext.ModelViews == null)
                {
                    CurrentDbContext.ModelViews = new List <ModelViewSerializable>();
                }
                foreach (ModelViewSerializable itm in srcContext.ModelViews)
                {
                    if (itm.RootEntityClassName != SelectedEntity.CodeElementName)
                    {
                        continue;
                    }
                    if (CurrentDbContext.ModelViews.Any(m => m.ViewName == itm.ViewName))
                    {
                        continue;
                    }
                    ModelViewSerializable destItm = itm.ModelViewSerializableGetCopy(this.DestinationProject, this.DefaultProjectNameSpace, this.DestinationFolder, this.DbSetProppertyName, this.SelectedEntity);
                    CurrentDbContext.ModelViews.Add(destItm);
                    ModelViews.Add(destItm);
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Error:" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #3
0
        public void OnForeignKeySelected(ModelViewForeignKey foreignKey)
        {
            if (ModelViews == null)
            {
                ModelViews = new ObservableCollection <ModelViewSerializable>();
            }
            if (foreignKey == null)
            {
                ModelViews.Clear();
                return;
            }
            if (ModelViews.Any(mv => ((mv.RootEntityFullClassName != foreignKey.NavigationEntityFullName) || (mv.RootEntityUniqueProjectName != foreignKey.NavigationEntityUniqueProjectName))))
            {
                ModelViews.Clear();
            }
            if (CurrentDbContext == null)
            {
                return;
            }
            if (CurrentDbContext.ModelViews == null)
            {
                return;
            }
            List <ModelViewSerializable> result = CurrentDbContext.ModelViews
                                                  .Where(mv => (mv.RootEntityFullClassName == foreignKey.NavigationEntityFullName) && (mv.RootEntityUniqueProjectName == foreignKey.NavigationEntityUniqueProjectName))
                                                  .ToList();

            if (result != null)
            {
                if (result.Count != ModelViews.Count)
                {
                    result.ForEach(r =>
                    {
                        if (!ModelViews.Any(mv => mv.ViewName == r.ViewName))
                        {
                            ModelViews.Add(r);
                        }
                    });
                }
            }
        }
 public void DoAnalize()
 {
     if (ModelViews == null)
     {
         ModelViews = new ObservableCollection <ModelViewSerializable>();
     }
     if ((ModelViews.Count > 0) || (SelectedEntity == null))
     {
         CheckIsReady();
         return;
     }
     if (CurrentDbContext.ModelViews != null)
     {
         foreach (ModelViewSerializable itm in CurrentDbContext.ModelViews)
         {
             if (itm.RootEntityFullClassName == SelectedEntity.CodeElementFullName)
             {
                 ModelViews.Add(itm);
             }
         }
     }
     CheckIsReady();
 }
Пример #5
0
        public override void Run()
        {
            using (var txn = model.BeginTransaction("Example"))
            {
                ModelViews.Add("ProductDataView");

                var lib = New <IfcProjectLibrary>(l => l.Name = "Air Terminal Library");
                var hz  = New <IfcSIUnit>(u =>
                {
                    u.Name     = Xbim.Ifc4.Interfaces.IfcSIUnitName.HERTZ;
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.FREQUENCYUNIT;
                });
                var watt = New <IfcSIUnit>(u =>
                {
                    u.Name     = Xbim.Ifc4.Interfaces.IfcSIUnitName.WATT;
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.POWERUNIT;
                });
                var db = New <IfcDerivedUnit>(u =>
                {
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcDerivedUnitEnum.SOUNDPRESSURELEVELUNIT;
                    u.Elements.Add(New <IfcDerivedUnitElement>(due =>
                    {
                        due.Exponent = 1;
                        due.Unit     = watt;
                    }));
                    u.Elements.Add(New <IfcDerivedUnitElement>(due =>
                    {
                        due.Exponent = -1;
                        due.Unit     = watt;
                    }));
                });
                lib.UnitsInContext = New <IfcUnitAssignment>(ua =>
                {
                    ua.Units.Add(hz);
                    ua.Units.Add(db);
                });

                var type = New <IfcAirTerminalType>(t => t.Name = "Air Terminal");
                New <IfcRelDeclares>(rel =>
                {
                    rel.RelatingContext = lib;
                    rel.RelatedDefinitions.Add(type);
                });
                var pset = New <IfcPropertySet>(ps =>
                {
                    ps.Name = "Air Terminal Properties";
                });
                type.HasPropertySets.Add(pset);

                var prop = New <IfcPropertyTableValue>(t =>
                {
                    t.Name         = "Acustic Performance [table of values]";
                    t.DefiningUnit = hz;
                    t.DefinedUnit  = db;
                    t.DefiningValues.AddRange(new IfcValue[] {
                        new IfcFrequencyMeasure(63),
                        new IfcFrequencyMeasure(125),
                        new IfcFrequencyMeasure(250),
                        new IfcFrequencyMeasure(500),
                        new IfcFrequencyMeasure(1000),
                        new IfcFrequencyMeasure(2000),
                        new IfcFrequencyMeasure(4000),
                        new IfcFrequencyMeasure(8000)
                    });
                    t.DefinedValues.AddRange(new IfcValue[] {
                        new IfcSoundPressureLevelMeasure(102),
                        new IfcSoundPressureLevelMeasure(99),
                        new IfcSoundPressureLevelMeasure(98),
                        new IfcSoundPressureLevelMeasure(98),
                        new IfcSoundPressureLevelMeasure(97),
                        new IfcSoundPressureLevelMeasure(95),
                        new IfcSoundPressureLevelMeasure(86),
                        new IfcSoundPressureLevelMeasure(81)
                    });
                });
                pset.HasProperties.Add(prop);

                var docProp = New <IfcPropertyReferenceValue>(r =>
                {
                    r.Name = "Acustic Performance [document reference]";
                    r.PropertyReference = New <IfcDocumentReference>(doc =>
                    {
                        doc.Name     = "Acustic Performance Documentation";
                        doc.Location = "https://www.daikinac.com/content/assets/DOC/EngineeringManuals/EDUS041501.pdf";
                    });
                });
                pset.HasProperties.Add(docProp);

                var fce = New <IfcPropertySingleValue>(r =>
                {
                    r.Name         = "Acustic Performance [function]";
                    r.NominalValue = new IfcText("0.0492424242 * Math.pow(x,4) - 1.0328282828 * Math.pow(x,3) + 6.8068181818 * Math.pow(x,2) - 17.753968254 * x + 114.14285714");
                    r.Description  = "ISO/IEC 22275:2018";
                });
                pset.HasProperties.Add(fce);

                txn.Commit();
            }

            // this will save .ifc, .ifcxml and .log with all potential schema errors
            SaveAs("properties", true, typeof(IfcProjectLibrary));
        }
Пример #6
0
        public override void Run()
        {
            using (var txn = model.BeginTransaction("Example"))
            {
                ModelViews.Add("ProductDataView");

                var lib = New <IfcProjectLibrary>(l => l.Name = "Declaration of Performance");
                Comment(lib, @"Root element of this file. Because this doesn't define a specific instance in the building it is a library.
It can be used to declare elements, properties, property templates and other library objects 
which can be later used in the actual design.");
                var mm = New <IfcSIUnit>(u =>
                {
                    u.Name     = Xbim.Ifc4.Interfaces.IfcSIUnitName.METRE;
                    u.Prefix   = Xbim.Ifc4.Interfaces.IfcSIPrefix.MILLI;
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.LENGTHUNIT;
                    Comment(u, @"All units are machine readable in IFC. They are either SI or their definitions
are infered from SI units. Because of that, relations between all units are well defined,
reliable and it is possible to validate them.");
                });
                lib.UnitsInContext = New <IfcUnitAssignment>(ua =>
                {
                    ua.Units.Add(mm);
                    Comment(ua, @"Units are assigned to the library project to that when units are not explicitely
defined for properties thay can be found on the project level. There are exact rules to find units for
all measure types (for example 'LENGTHUNIT' for 'IfcLengthMeasue' etc.)");
                });

                var declarations = New <IfcRelDeclares>(rel =>
                {
                    rel.RelatingContext = lib;
                }).RelatedDefinitions;
                Comment(declarations.OwningEntity, @"This relation points to all definitions declared within the scope of the library.
These can be elements, element types, properties or property templates");

                var psetTemplate = New <IfcPropertySetTemplate>(ps =>
                {
                    ps.Name             = "Essential Characteristics";
                    ps.ApplicableEntity = nameof(IfcBuildingElementPart);
                    ps.TemplateType     = Xbim.Ifc4.Interfaces.IfcPropertySetTemplateTypeEnum.PSET_TYPEDRIVENOVERRIDE;
                });
                Comment(psetTemplate, @"Template of the property set is used to group properties in logical groups.
This can contain any number of properties with the name unique within the set. 'IfcBuildingElementPart' is the best IFC
entity type fit for a brick so it is used as the applicable entity definition");

                declarations.Add(psetTemplate);

                var lengthTemplate = New <IfcComplexPropertyTemplate>(t =>
                {
                    t.Name      = "dimensions";
                    t.UsageName = "dimensions";
                    t.HasPropertyTemplates.Add(
                        New <IfcSimplePropertyTemplate>(v =>
                    {
                        v.Name               = "length";
                        v.TemplateType       = Xbim.Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE;
                        v.PrimaryUnit        = mm;
                        v.PrimaryMeasureType = nameof(IfcLengthMeasure);
                        Comment(v, "Simple name-definition-value property template defining actual value, type of measure (length) and unit (mm)");

                        New <IfcRelAssociatesConstraint>(r =>
                        {
                            r.RelatedObjects.Add(v);
                            r.RelatingConstraint = New <IfcMetric>(m =>
                            {
                                m.Name            = "Required length";
                                m.ConstraintGrade = Xbim.Ifc4.Interfaces.IfcConstraintEnum.HARD;
                                m.Benchmark       = Xbim.Ifc4.Interfaces.IfcBenchmarkEnum.EQUALTO;
                                m.DataValue       = new IfcLengthMeasure(300);
                                Comment(m, "Metric constraint used to define required value of 300 mm");
                            });
                            Comment(r, "Relation used to set a constraint on the template property");
                        });
                    })
                        );
                });
                psetTemplate.HasPropertyTemplates.Add(lengthTemplate);
                Comment(lengthTemplate, @"Complex property template is used to describe all aspects of the property. 
Both property set template and property template have globally unique GUID which can be used for 
global management of definitions and to maintain relations to data dictionaries. ");

                var docRel = New <IfcRelAssociatesDocument>(r =>
                {
                    r.RelatedObjects.Add(lengthTemplate);
                    r.RelatingDocument = New <IfcDocumentReference>(d =>
                    {
                        d.Name           = "EN 772-1";
                        d.Location       = new IfcURIReference("https://standards.cen.eu");
                        d.Identification = "3bhhlYovD1xOzSEP5n2HRY";
                        Comment(d, "Document reference pointing to relevant document. GUID is used for unique identification.");
                    });
                });
                Comment(docRel, @"Relation associates this property template with the document reference");


                Comment(lib.OwnerHistory, @"Owner history is used to define ownership of the information.");

                txn.Commit();
            }

            SaveAs("Example_7_Dimensions", true, typeof(IfcProjectLibrary));
        }