private void CreateMaterialLayers(IBimBuildingElementType tType, XbimBuildingElementType sType)
        {
            foreach (XbimMaterialLayer layer in sType.MaterialLayers)
            {
                string matName = layer.Material.Name;
                
                IBimMaterial material = Target.GetMaterial(matName);
                if (material == null) material = Source.MaterialHelper.Convert(layer.Material);

                int layerIndex = sType.MaterialLayers.IndexOf(layer);
                tType.AddMaterialLayer(material, layer.Thickness, false, sType.GetMaterialFunction(layerIndex));
            }
        }
        private IBimBuildingElementType BaseConversion(IBimBuildingElementType tType, XbimBuildingElementType sType)
        {

            //set guid
            tType.GlobalId = sType.Guid;

            //set material layers if it exists in the object and object has appropriate type
            CreateMaterialLayers(tType, sType);

            //parameters
            PropertiesHelper.Convert(tType.Properties, sType.Properties);

            //add converted element to the stack of converted elements
            Source.AddConvertedObject(sType);

            return tType;


        }
Example #3
0
 public double? GetVolumeForElement(XbimBuildingElementType buildingElementType)
 {
     XbimMaterialQuantities quantities = buildingElementType.MaterialQuantities;
     return quantities.GetMaterialVolume(this);
 }
        //recursive function - check tne uniqueness of the name of the type 
        //in the target document. If the name already exists it is changed
        //in the source model so that it can be used later
        private bool CheckName(XbimBuildingElementType xType) 
        {
            if (!_checkNames) return true;

            string name = xType.Name;
            IBimBuildingElementType tType = Target.GetBuildingElementType(name);
            if (tType != null)
            { 
                int index = name.Length - 2; //ge_t character one before the end
                char testChar = name[index];
                if (testChar == '_')
                {
                    char last = name.LastOrDefault(); //last character
                    int number = 1;
                    if (int.TryParse(last.ToString(), out number))
                    {
                        name = name.Substring(0, name.Length - 1);
                        name += number + 1;
                    }
                    else
                    {
                        name += "_1";
                    }
                }
                else
                {
                    name += "_1";
                }
                xType.Name = name;
                return CheckName(xType);
            }
            return true;
        }
Example #5
0
 internal NRMQuantities(XbimBuildingElementType elemType) : base(elemType.IfcTypeProduct, "NRM") { }
Example #6
0
 public IEnumerable<XbimBuildingElement> GetElementsOfType(XbimBuildingElementType type)
 {
     return AllBuildingElements.Where(el => el.IfcTypeObject == type.IfcTypeProduct);
 }
Example #7
0
        public bool InsertBuildingElementType (XbimBuildingElementType newType)
        {
            //XbimBuildingElementType test = AllBuildingElementTypes.Where(t => t == newType || t.GlobalId == newType.GlobalId).FirstOrDefault();
            //if (test != null) return false; //if it is already there there is no point in inserting that

            ////if model is Transient model it is possible to use side effect
            //XbimMemoryModel model = Model as XbimMemoryModel;
            //if (model != null)
            //{
            //    //create new actual owner history with proper state
            //    newType.IfcTypeProduct.OwnerHistory = GetNewOwnerHistory(IfcChangeActionEnum.ADDED);
            //    model.AddNew(newType.IfcTypeProduct);
            //    return true;
            //}
 
            //other types of models are not supported at the moment
            throw new NotImplementedException(); //todo: implement inserting of elements
        }
Example #8
0
        public void ChangeElementsType(XbimBuildingElementType oldType, XbimBuildingElementType newType)
        {
            if (oldType == newType || oldType.GlobalId == newType.GlobalId) return;  //no processing if the elements are the same ones

            if (oldType.Document != newType.Document)
            {
                InsertBuildingElementType(newType); //insert new type if it is not present in the actual document
            }
            IEnumerable<XbimBuildingElement> elements = GetElementsOfType(oldType);
            foreach (var element in elements)
            {
                //change Type
                element.IfcTypeObject = newType.IfcTypeProduct;

                //change state in owner history to modified so that we can get the modified data quickly "GetModifiedBuildingElements()"
                IfcBuildingElement ifcElement = element.IfcBuildingElement;
                ifcElement.OwnerHistory.ChangeAction = Ifc2x3.UtilityResource.IfcChangeActionEnum.MODIFIED;
            }
        }