Esempio n. 1
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();
            }
        }