예제 #1
0
        /// <summary>
        /// Sets integer attribute for the handle.
        /// </summary>
        /// <param name="handle">The handle.</param>
        /// <param name="name">The attribute name.</param>
        /// <param name="value">The intereger value.</param>
        /// <exception cref="ArgumentException">If the name is null or empty.</exception>
        public static void SetAttribute(IFCAnyHandle handle, string name, int value)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The name is empty.", "name");
            }

            handle.SetAttribute(name, value);
        }
예제 #2
0
        /// <summary>
        /// Sets logical attribute for the handle.
        /// </summary>
        /// <remarks>
        /// If value is null or empty, the attribute will be unset.
        /// </remarks>
        /// <param name="handle">The handle.</param>
        /// <param name="name">The attribute name.</param>
        /// <param name="value">The logical value.</param>
        /// <exception cref="ArgumentException">If the name is null or empty.</exception>
        public static void SetAttribute(IFCAnyHandle handle, string name, IFCLogical value)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The name is empty.", "name");
            }

            handle.SetAttribute(name, IFCData.CreateLogical(value));
        }
예제 #3
0
        /// <summary>
        /// Sets string aggregate attribute for the handle.
        /// </summary>
        /// <remarks>
        /// If values collection is null, the attribute will be unset.
        /// </remarks>
        /// <param name="handle">The handle.</param>
        /// <param name="name">The attribute name.</param>
        /// <param name="values">The values.</param>
        /// <exception cref="ArgumentException">If the name is null or empty.</exception>
        public static void SetAttribute(IFCAnyHandle handle, string name, ICollection <string> values)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The name is empty.", "name");
            }

            if (values != null)
            {
                handle.SetAttribute(name, values);
            }
        }
예제 #4
0
        /// <summary>
        /// Sets boolean attribute for the handle.
        /// </summary>
        /// <remarks>
        /// If value is null, the attribute will be unset.
        /// </remarks>
        /// <param name="handle">The handle.</param>
        /// <param name="name">The attribute name.</param>
        /// <param name="value">The boolean value.</param>
        /// <exception cref="ArgumentException">If the name is null or empty.</exception>
        public static void SetAttribute(IFCAnyHandle handle, string name, bool?value)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The name is empty.", "name");
            }

            if (value != null)
            {
                handle.SetAttribute(name, (bool)value);
            }
        }
예제 #5
0
        /// <summary>
        /// Sets enumeration attribute for the handle.
        /// </summary>
        /// <remarks>
        /// If value is null or empty, the attribute will be unset.
        /// </remarks>
        /// <param name="handle">The handle.</param>
        /// <param name="name">The attribute name.</param>
        /// <param name="value">The enumeration value.</param>
        /// <exception cref="ArgumentException">If the name is null or empty.</exception>
        public static void SetAttribute(IFCAnyHandle handle, string name, Enum value)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The name is empty.", "name");
            }

            if (value != null)
            {
                handle.SetAttribute(name, IFCData.CreateEnumeration(value.ToString()));
            }
        }
 private static void SetSurfaceStyleShading(IFCAnyHandle surfaceStyleRendering, IFCAnyHandle surfaceColour)
 {
    surfaceStyleRendering.SetAttribute("SurfaceColour", surfaceColour);
 }
        /// <summary>
        /// Creates and associates the common property sets associated with ElementTypes.  These are handled differently than for elements.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="elementType">The element type whose properties are exported.</param>
        /// <param name="existingPropertySets">The handles of property sets already associated with the type.</param>
        /// <param name="prodTypeHnd">The handle of the entity associated with the element type object.</param>
        public static void CreateElementTypeProperties(ExporterIFC exporterIFC, ElementType elementType,
            HashSet<IFCAnyHandle> existingPropertySets, IFCAnyHandle prodTypeHnd)
        {
            HashSet<IFCAnyHandle> propertySets = new HashSet<IFCAnyHandle>();

            // Pass in an empty set of handles - we don't want IfcRelDefinesByProperties for type properties.
            ISet<IFCAnyHandle> associatedObjectIds = new HashSet<IFCAnyHandle>();
            PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, elementType, associatedObjectIds);

            TypePropertyInfo additionalPropertySets = null;
            if (ExporterCacheManager.TypePropertyInfoCache.TryGetValue(elementType.Id, out additionalPropertySets))
                propertySets.UnionWith(additionalPropertySets.PropertySets);

            if (existingPropertySets != null && existingPropertySets.Count > 0)
                propertySets.UnionWith(existingPropertySets);

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                Document doc = elementType.Document;
                IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

                IList<IList<PropertySetDescription>> psetsToCreate = ExporterCacheManager.ParameterCache.PropertySets;

                IList<PropertySetDescription> currPsetsToCreate = ExporterUtil.GetCurrPSetsToCreate(prodTypeHnd, psetsToCreate);
                foreach (PropertySetDescription currDesc in currPsetsToCreate)
                {
                    HashSet<IFCAnyHandle> props = currDesc.ProcessEntries(file, exporterIFC, null, elementType, elementType);
                    if (props.Count > 0)
                    {
                        int subElementIndex = currDesc.SubElementIndex;
                        string guid = GUIDUtil.CreateSubElementGUID(elementType, subElementIndex);

                        string paramSetName = currDesc.Name;
                        IFCAnyHandle propertySet = IFCInstanceExporter.CreatePropertySet(file, guid, ownerHistory, paramSetName, null, props);
                        propertySets.Add(propertySet);
                    }
                }

                if (propertySets.Count != 0)
                {
                    prodTypeHnd.SetAttribute("HasPropertySets", propertySets);
                    // Don't assign the property sets to the instances if we have just assigned them to the type.
                    if (additionalPropertySets != null)
                        additionalPropertySets.AssignedToType = true;
                }

                transaction.Commit();
            }
        }
예제 #8
0
        /// <summary>
        /// Creates and associates the common property sets associated with ElementTypes.  These are handled differently than for elements.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="elementType">The element type whose properties are exported.</param>
        /// <param name="existingPropertySets">The handles of property sets already associated with the type.</param>
        /// <param name="prodTypeHnd">The handle of the entity associated with the element type object.</param>
        public static void CreateElementTypeProperties(ExporterIFC exporterIFC, ElementType elementType, 
            HashSet<IFCAnyHandle> existingPropertySets, IFCAnyHandle prodTypeHnd)
        {
            HashSet<IFCAnyHandle> propertySets = new HashSet<IFCAnyHandle>();
            propertySets.UnionWith(existingPropertySets);

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                Document doc = elementType.Document;

                IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

                IList<IList<PropertySetDescription>> psetsToCreate = ExporterCacheManager.ParameterCache.PropertySets;

                IList<PropertySetDescription> currPsetsToCreate = GetCurrPSetsToCreate(prodTypeHnd, psetsToCreate);
                foreach (PropertySetDescription currDesc in currPsetsToCreate)
                {
                    HashSet<IFCAnyHandle> props = currDesc.ProcessEntries(file, exporterIFC, null, elementType, elementType);
                    if (props.Count > 0)
                    {
                        int subElementIndex = currDesc.SubElementIndex;
                        string guid = GUIDUtil.CreateSubElementGUID(elementType, subElementIndex);

                        string paramSetName = currDesc.Name;
                        IFCAnyHandle propertySet = IFCInstanceExporter.CreatePropertySet(file, guid, ownerHistory, paramSetName, null, props);
                        propertySets.Add(propertySet);
                    }
                }

                if (propertySets.Count != 0)
                    prodTypeHnd.SetAttribute("HasPropertySets", propertySets);

                transaction.Commit();
            }
        }