/// <summary>
        /// Creates handles for the properties.
        /// </summary>
        /// <param name="file">The IFC file.</param>
        /// <param name="exporterIFC">The ExporterIFC class.</param>
        /// <param name="ifcParams">The extrusion creation data, used to get extra parameter information.</param>
        /// <param name="elementOrConnectorToUse">The base element or connector.</param>
        /// <param name="elemTypeToUse">The base element type.</param>
        /// <param name="handle">The handle for which we process the entries.</param>
        /// <returns>A set of property handles.</returns>
        public ISet <IFCAnyHandle> ProcessEntries(IFCFile file, ExporterIFC exporterIFC, IFCExtrusionCreationData ifcParams,
                                                  ElementOrConnector elementOrConnectorToUse, ElementType elemTypeToUse, IFCAnyHandle handle)
        {
            // We need to ensure that we don't have the same property name twice in the same property set.
            // By convention, we will keep the last property with the same name.  This allows for a user-defined
            // property set to look at both the type and the instance for a property value, if the type and instance properties
            // have different names.
            IDictionary <string, IFCAnyHandle> propertiesByName = new SortedDictionary <string, IFCAnyHandle>();

            bool fromSchedule = ExporterCacheManager.ViewScheduleElementCache.ContainsKey(this.ViewScheduleId);

            foreach (PropertySetEntry entry in m_Entries)
            {
                try
                {
                    IFCAnyHandle propHnd = entry.ProcessEntry(file, exporterIFC, Name, ifcParams, elementOrConnectorToUse, elemTypeToUse, handle, fromSchedule);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(propHnd))
                    {
                        continue;
                    }

                    string currPropertyName = UsablePropertyName(propHnd, propertiesByName);
                    if (currPropertyName != null)
                    {
                        propertiesByName[currPropertyName] = propHnd;
                    }
                }
                catch (Exception) { }
            }

            ISet <IFCAnyHandle> props = new HashSet <IFCAnyHandle>(propertiesByName.Values);

            return(props);
        }
Esempio n. 2
0
        /// <summary>
        /// Export porterty sets for the connector
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="connector">The connector to export properties for.</param>
        /// <param name="handle">The ifc handle of exported connector.</param>
        private static void ExportConnectorProperties(ExporterIFC exporterIFC, Connector connector,
                                                      IFCAnyHandle handle)
        {
            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
                IList <IList <PropertySetDescription> > psetsToCreate = ExporterCacheManager.ParameterCache.PropertySets;
                if (IFCAnyHandleUtil.IsNullOrHasNoValue(handle))
                {
                    return;
                }

                IList <PropertySetDescription> currPsetsToCreate = ExporterUtil.GetCurrPSetsToCreate(handle, psetsToCreate);
                if (currPsetsToCreate.Count == 0)
                {
                    return;
                }

                foreach (PropertySetDescription currDesc in currPsetsToCreate)
                {
                    ElementOrConnector  elementOrConnector = new ElementOrConnector(connector);
                    ISet <IFCAnyHandle> props = currDesc.ProcessEntries(file, exporterIFC, null,
                                                                        elementOrConnector, null, handle);
                    if (props.Count < 1)
                    {
                        continue;
                    }

                    string guid = GUIDUtil.GenerateIFCGuidFrom(IFCEntityType.IfcPropertySet, currDesc.Name,
                                                               handle);
                    IFCAnyHandle propertySet = IFCInstanceExporter.CreatePropertySet(file,
                                                                                     guid, ownerHistory, currDesc.Name, currDesc.DescriptionOfSet,
                                                                                     props);
                    if (propertySet == null)
                    {
                        continue;
                    }

                    HashSet <IFCAnyHandle> relatedObjects = new HashSet <IFCAnyHandle>()
                    {
                        handle
                    };
                    ExporterUtil.CreateRelDefinesByProperties(file, ownerHistory, null, null,
                                                              relatedObjects, propertySet);
                }
                transaction.Commit();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Process to create element or connector property.
        /// </summary>
        /// <param name="file">The IFC file.</param>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="owningPsetName">Name of Property Set this entry belongs to .</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="elementOrConnector">The element or connector of which this property is created for.</param>
        /// <param name="elementType">The element type of which this property is created for.</param>
        /// <param name="handle">The handle for which this property is created for.</param>
        /// <returns>The created property handle.</returns>
        public IFCAnyHandle ProcessEntry(IFCFile file, ExporterIFC exporterIFC, string owningPsetName,
                                         IFCExtrusionCreationData extrusionCreationData, ElementOrConnector elementOrConnector,
                                         ElementType elementType, IFCAnyHandle handle, bool fromSchedule = false)
        {
            // if CombinedParameterData, then we have to recreate the parameter value, since there is no
            // API for this.
            if (CombinedParameterData != null)
            {
                return(CreateTextPropertyFromCombinedParameterData(file, elementOrConnector.Element));
            }

            // Otherwise, do standard processing.
            foreach (PropertySetEntryMap map in Entries)
            {
                IFCAnyHandle propHnd = map.ProcessEntry(file, exporterIFC, owningPsetName,
                                                        extrusionCreationData, elementOrConnector, elementType, handle, PropertyType,
                                                        PropertyArgumentType, PropertyValueType, PropertyEnumerationType, PropertyName, fromSchedule);
                if (propHnd != null)
                {
                    return(propHnd);
                }
            }

            return(SetDefaultProperty(file));
        }