protected virtual void CreateParametersInternal(Document doc, Element element)
        {
            if (element != null)
            {
                // Set the element name.
                SetName(doc, element);

                // Set the element description.
                SetDescription(doc, element);

                // The list of materials.
                SetMaterialParameter(doc, element);

                // Set the "IfcSystem" parameter.
                SetSystemParameter(doc, element);

                // Set the element GUID.
                bool             elementIsType = (element is ElementType);
                BuiltInParameter ifcGUIDId     = GetGUIDParameter(element, elementIsType);
                Parameter        guidParam     = element.get_Parameter(ifcGUIDId);
                if (guidParam != null)
                {
                    if (!guidParam.IsReadOnly)
                    {
                        guidParam.Set(GlobalId);
                    }
                }
                else
                {
                    ExporterIFCUtils.AddValueString(element, new ElementId(ifcGUIDId), GlobalId);
                }

                // Set the "IfcExportAs" parameter.
                string ifcExportAs = IFCCategoryUtil.GetCustomCategoryName(this);
                if (!string.IsNullOrWhiteSpace(ifcExportAs))
                {
                    IFCPropertySet.AddParameterString(doc, element, "IfcExportAs", ifcExportAs, Id);
                }

                // Add property set-based parameters.
                // We are going to create this "fake" parameter so that we can filter elements in schedules based on their property sets.
                string propertySetListName = elementIsType ? "Type IfcPropertySetList" : "IfcPropertySetList";
                IFCPropertySet.AddParameterString(doc, element, propertySetListName, "", Id);

                // Set the IFCElementAssembly Parameter
                if (Decomposes != null && Decomposes is IFCElementAssembly)
                {
                    IFCPropertySet.AddParameterString(doc, element, "IfcElementAssembly", Decomposes.Name, Id);
                }
            }
        }
예제 #2
0
        protected virtual void CreateParametersInternal(Document doc, Element element)
        {
            if (element != null)
            {
                // Set the element name.
                SetName(doc, element);

                // Set the element description.
                SetDescription(doc, element);

                // The list of materials.
                SetMaterialParameter(doc, element);

                // Set the "IfcSystem" parameter.
                SetSystemParameter(doc, element);

                // Set the element GUID.
                bool             elementIsType = (element is ElementType);
                BuiltInParameter ifcGUIDId     = GetGUIDParameter(element, elementIsType);
                Parameter        guidParam     = element.get_Parameter(ifcGUIDId);
                if (guidParam != null)
                {
                    if (!guidParam.IsReadOnly)
                    {
                        guidParam.Set(GlobalId);
                    }
                }
                else
                {
                    ExporterIFCUtils.AddValueString(element, new ElementId(ifcGUIDId), GlobalId);
                }

                // Set the "IfcExportAs" parameter.
                string ifcExportAs = IFCCategoryUtil.GetCustomCategoryName(this);
                if (!string.IsNullOrWhiteSpace(ifcExportAs))
                {
                    IFCPropertySet.AddParameterString(doc, element, "IfcExportAs", ifcExportAs, Id);
                }

                // Add property set-based parameters.
                // We are going to create this "fake" parameter so that we can filter elements in schedules based on their property sets.
                string propertySetListName = elementIsType ? "Type IfcPropertySetList" : "IfcPropertySetList";
                IFCPropertySet.AddParameterString(doc, element, propertySetListName, "", Id);

                // Set the IFCElementAssembly Parameter
                if (Decomposes != null && Decomposes is IFCElementAssembly)
                {
                    IFCPropertySet.AddParameterString(doc, element, "IfcElementAssembly", Decomposes.Name, Id);
                }

                // Set additional parameters (if any), e.g. for Classification assignments
                if (AdditionalIntParameters.Count > 0)
                {
                    foreach (KeyValuePair <string, object> parItem in AdditionalIntParameters)
                    {
                        if (parItem.Value is string)
                        {
                            IFCPropertySet.AddParameterString(doc, element, parItem.Key, (string)parItem.Value, Id);
                        }
                        else if (parItem.Value is double)
                        {
                            IFCPropertySet.AddParameterDouble(doc, element, parItem.Key, UnitType.UT_Custom, (double)parItem.Value, Id);
                        }
                        else if (parItem.Value is int)
                        {
                            IFCPropertySet.AddParameterInt(doc, element, parItem.Key, (int)parItem.Value, Id);
                        }
                        else if (parItem.Value is bool)
                        {
                            IFCPropertySet.AddParameterBoolean(doc, element, parItem.Key, (bool)parItem.Value, Id);
                        }
                    }
                }
            }
        }
예제 #3
0
        protected virtual void CreateParametersInternal(Document doc, Element element)
        {
            if (element != null)
            {
                Category category = IFCPropertySet.GetCategoryForParameterIfValid(element, Id);

                // Set the element name.
                SetName(doc, element, category);

                // Set the element description.
                SetDescription(doc, element, category);

                // The list of materials.
                SetMaterialParameter(doc, element, category);

                // Set the "IfcSystem" parameter.
                SetSystemParameter(doc, element, category);

                // Set the element GUID.
                bool             elementIsType = (element is ElementType);
                BuiltInParameter ifcGUIDId     = GetGUIDParameter(element, elementIsType);
                Parameter        guidParam     = element.get_Parameter(ifcGUIDId);
                if (guidParam != null)
                {
                    if (!guidParam.IsReadOnly)
                    {
                        guidParam.Set(GlobalId);
                    }
                }
                else
                {
                    ExporterIFCUtils.AddValueString(element, new ElementId(ifcGUIDId), GlobalId);
                }

                // Set the "IfcExportAs" parameter.
                string ifcExportAs = IFCCategoryUtil.GetCustomCategoryName(this);
                if (!string.IsNullOrWhiteSpace(ifcExportAs))
                {
                    IFCPropertySet.AddParameterString(doc, element, category, this, IFCSharedParameters.IfcExportAs, ifcExportAs, Id);
                }

                // Set the IFCElementAssembly Parameter
                if (Decomposes != null)
                {
                    string containerParamName     = (Decomposes is IFCElementAssembly) ? "IfcElementAssembly" : "IfcDecomposes";
                    string containerParamGUIDName = (Decomposes is IFCElementAssembly) ? "IfcElementAssemblyGUID" : "IfcDecomposesGUID";
                    IFCPropertySet.AddParameterString(doc, element, category, containerParamName, Decomposes.Name, Id);
                    IFCPropertySet.AddParameterString(doc, element, category, containerParamGUIDName, Decomposes.GlobalId, Id);
                }

                // Set additional parameters (if any), e.g. for Classification assignments
                if (AdditionalIntParameters.Count > 0)
                {
                    foreach (KeyValuePair <string, object> parItem in AdditionalIntParameters)
                    {
                        if (parItem.Value is string)
                        {
                            IFCPropertySet.AddParameterString(doc, element, category, parItem.Key, (string)parItem.Value, Id);
                        }
                        else if (parItem.Value is double)
                        {
                            IFCPropertySet.AddParameterDouble(doc, element, category, parItem.Key, SpecTypeId.Custom, (double)parItem.Value, Id);
                        }
                        else if (parItem.Value is int)
                        {
                            IFCPropertySet.AddParameterInt(doc, element, category, parItem.Key, (int)parItem.Value, Id);
                        }
                        else if (parItem.Value is bool)
                        {
                            IFCPropertySet.AddParameterBoolean(doc, element, category, parItem.Key, (bool)parItem.Value, Id);
                        }
                    }
                }
            }
        }