Example #1
0
        /// <summary>
        /// Creates a Project, Site, or Building GUID.  If a shared parameter is set with a valid IFC GUID value,
        /// that value will override the default one.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="guidType">The GUID being created.</param>
        /// <returns>The IFC GUID value.</returns>
        /// <remarks>For Sites, the user should only use this routine if there is no Site element in the file.  Otherwise, they
        /// should use CreateSiteGUID below, which takes an Element pointer.</remarks>
        static public string CreateProjectLevelGUID(Document document, IFCProjectLevelGUIDType guidType)
        {
            string      parameterName = "Ifc" + guidType.ToString() + " GUID";
            ProjectInfo projectInfo   = document.ProjectInformation;

            BuiltInParameter parameterId = BuiltInParameter.INVALID;

            switch (guidType)
            {
            case IFCProjectLevelGUIDType.Building:
                parameterId = BuiltInParameter.IFC_BUILDING_GUID;
                break;

            case IFCProjectLevelGUIDType.Project:
                parameterId = BuiltInParameter.IFC_PROJECT_GUID;
                break;

            case IFCProjectLevelGUIDType.Site:
                parameterId = BuiltInParameter.IFC_SITE_GUID;
                break;

            default:
                // This should eventually log an error.
                return(null);
            }

            if (projectInfo != null)
            {
                string paramValue = null;
                ParameterUtil.GetStringValueFromElement(projectInfo, parameterName, out paramValue);
                if (!IsValidIFCGUID(paramValue) && parameterId != BuiltInParameter.INVALID)
                {
                    ParameterUtil.GetStringValueFromElement(projectInfo, parameterId, out paramValue);
                }

                if (IsValidIFCGUID(paramValue))
                {
                    return(paramValue);
                }
            }

            // Only for 2022
            //ElementId projectLevelElementId = new ElementId((int)guidType);
            //System.Guid guid = ExportUtils.GetExportId(document, projectLevelElementId);
            //string ifcGUID = ConvertToIFCGuid(guid);
            string ifcGUID = ExporterIFCUtils.CreateProjectLevelGUID(document, guidType);

            if ((projectInfo != null) && ExporterCacheManager.ExportOptionsCache.GUIDOptions.StoreIFCGUID)
            {
                if (parameterId != BuiltInParameter.INVALID)
                {
                    ExporterCacheManager.GUIDsToStoreCache[new KeyValuePair <ElementId, BuiltInParameter>(projectInfo.Id, parameterId)] = ifcGUID;
                }
            }
            return(ifcGUID);
        }
Example #2
0
        /// <summary>
        /// Creates a Project, Site, or Building GUID.  If a shared parameter is set with a valid IFC GUID value,
        /// that value will override the default one.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="guidType">The GUID being created.</param>
        /// <returns>The IFC GUID value.</returns>
        /// <remarks>For Sites, the user should only use this routine if there is no Site element in the file.  Otherwise, they
        /// should use CreateSiteGUID below, which takes an Element pointer.</remarks>
        static public string CreateProjectLevelGUID(Document document, IFCProjectLevelGUIDType guidType)
        {
            string      parameterName = "Ifc" + guidType.ToString() + " GUID";
            ProjectInfo projectInfo   = document.ProjectInformation;

            BuiltInParameter parameterId = BuiltInParameter.INVALID;

            switch (guidType)
            {
            case IFCProjectLevelGUIDType.Building:
                parameterId = BuiltInParameter.IFC_BUILDING_GUID;
                break;

            case IFCProjectLevelGUIDType.Project:
                parameterId = BuiltInParameter.IFC_PROJECT_GUID;
                break;

            case IFCProjectLevelGUIDType.Site:
                parameterId = BuiltInParameter.IFC_SITE_GUID;
                break;
            }

            if (projectInfo != null)
            {
                string paramValue = null;
                ParameterUtil.GetStringValueFromElement(projectInfo, parameterName, out paramValue);
                if ((paramValue != null) && (IsValidIFCGUID(paramValue)))
                {
                    return(paramValue);
                }
                if (parameterId != BuiltInParameter.INVALID && ParameterUtil.GetStringValueFromElement(projectInfo, parameterId, out paramValue) != null)
                {
                    return(paramValue);
                }
            }
            string guid = ExporterIFCUtils.CreateProjectLevelGUID(document, guidType);

            if ((projectInfo != null) && ExporterCacheManager.ExportOptionsCache.GUIDOptions.StoreIFCGUID)
            {
                if (parameterId != BuiltInParameter.INVALID)
                {
                    ExporterCacheManager.GUIDsToStoreCache[new KeyValuePair <Element, BuiltInParameter>(projectInfo, parameterId)] = guid;
                }
            }
            return(guid);
        }
Example #3
0
        /// <summary>
        /// Creates a Project, Site, or Building GUID.  If a shared parameter is set with a valid IFC GUID value,
        /// that value will override the default one.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="guidType">The GUID being created.</param>
        /// <returns>The IFC GUID value.</returns>
        /// <remarks>For Sites, the user should only use this routine if there is no Site element in the file.  Otherwise, they
        /// should use CreateSiteGUID below, which takes an Element pointer.</remarks>
        static public string CreateProjectLevelGUID(Document document, IFCProjectLevelGUIDType guidType)
        {
            string      parameterName = "Ifc" + guidType.ToString() + " GUID";
            ProjectInfo projectInfo   = document.ProjectInformation;

            if (projectInfo != null)
            {
                string paramValue = null;
                ParameterUtil.GetStringValueFromElement(projectInfo.Id, parameterName, out paramValue);
                if ((paramValue != null) && (IsValidIFCGUID(paramValue)))
                {
                    return(paramValue);
                }
            }

            // CreateProjectLevelGUID will throw an exception if the is no Project Information, which indicates
            // some sort of error in the document.  Don't bother trying to create a consistent GUID in this case.
            // This is fixed in 2014+.
            string guid = (projectInfo != null) ? ExporterIFCUtils.CreateProjectLevelGUID(document, guidType) : CreateGUID();

            if ((projectInfo != null) && ExporterCacheManager.ExportOptionsCache.GUIDOptions.StoreIFCGUID)
            {
                BuiltInParameter parameterId = BuiltInParameter.INVALID;
                switch (guidType)
                {
                case IFCProjectLevelGUIDType.Building:
                    parameterId = BuiltInParameter.IFC_BUILDING_GUID;
                    break;

                case IFCProjectLevelGUIDType.Project:
                    parameterId = BuiltInParameter.IFC_PROJECT_GUID;
                    break;

                case IFCProjectLevelGUIDType.Site:
                    parameterId = BuiltInParameter.IFC_SITE_GUID;
                    break;
                }

                if (parameterId != BuiltInParameter.INVALID)
                {
                    IFCStoredGUID.ProjectInfoParameterGUID[parameterId] = guid;
                }
            }
            return(guid);
        }
Example #4
0
        /// <summary>
        /// Creates a Project, Site, or Building GUID.  If a shared parameter is set with a valid IFC GUID value,
        /// that value will override the default one.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="guidType">The GUID being created.</param>
        /// <returns>The IFC GUID value.</returns>
        /// <remarks>For Sites, the user should only use this routine if there is no Site element in the file.  Otherwise, they
        /// should use CreateSiteGUID below, which takes an Element pointer.</remarks>
        public static string CreateProjectLevelGUID(Document document, IFCProjectLevelGUIDType guidType)
        {
            string parameterName = "Ifc" + guidType.ToString() + " GUID";
            ProjectInfo projectInfo = document.ProjectInformation;

            if (projectInfo != null)
            {
                string paramValue = null;
                ParameterUtil.GetStringValueFromElement(projectInfo, parameterName, out paramValue);
                if ((paramValue != null) && (IsValidIFCGUID(paramValue)))
                    return paramValue;
            }

            return ExporterIFCUtils.CreateProjectLevelGUID(document, guidType);
        }
        /// <summary>
        /// Creates a Project, Site, or Building GUID.  If a shared parameter is set with a valid IFC GUID value,
        /// that value will override the default one.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="guidType">The GUID being created.</param>
        /// <returns>The IFC GUID value.</returns>
        /// <remarks>For Sites, the user should only use this routine if there is no Site element in the file.  Otherwise, they
        /// should use CreateSiteGUID below, which takes an Element pointer.</remarks>
        static public string CreateProjectLevelGUID(Document document, IFCProjectLevelGUIDType guidType)
        {
            string parameterName = "Ifc" + guidType.ToString() + " GUID";
            ProjectInfo projectInfo = document.ProjectInformation;

            if (projectInfo != null)
            {
                string paramValue = null;
                ParameterUtil.GetStringValueFromElement(projectInfo.Id, parameterName, out paramValue);
                if ((paramValue != null) && (IsValidIFCGUID(paramValue)))
                    return paramValue;
            }

            // CreateProjectLevelGUID will throw an exception if the is no Project Information, which indicates
            // some sort of error in the document.  Don't bother trying to create a consistent GUID in this case.
            // This is fixed in 2014+.
            string guid = (projectInfo != null) ? ExporterIFCUtils.CreateProjectLevelGUID(document, guidType) : CreateGUID();

            if ((projectInfo != null) && ExporterCacheManager.ExportOptionsCache.GUIDOptions.StoreIFCGUID)
            {
                BuiltInParameter parameterId = BuiltInParameter.INVALID;
                switch (guidType)
                {
                    case IFCProjectLevelGUIDType.Building:
                        parameterId = BuiltInParameter.IFC_BUILDING_GUID;
                        break;
                    case IFCProjectLevelGUIDType.Project:
                        parameterId = BuiltInParameter.IFC_PROJECT_GUID;
                        break;
                    case IFCProjectLevelGUIDType.Site:
                        parameterId = BuiltInParameter.IFC_SITE_GUID;
                        break;
                }
                
                if (parameterId != BuiltInParameter.INVALID)
                    IFCStoredGUID.ProjectInfoParameterGUID[parameterId] = guid;
            }
            return guid;
        }
        /// <summary>
        /// Creates a Project, Site, or Building GUID.  If a shared parameter is set with a valid IFC GUID value,
        /// that value will override the default one.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="guidType">The GUID being created.</param>
        /// <returns>The IFC GUID value.</returns>
        /// <remarks>For Sites, the user should only use this routine if there is no Site element in the file.  Otherwise, they
        /// should use CreateSiteGUID below, which takes an Element pointer.</remarks>
        static public string CreateProjectLevelGUID(Document document, IFCProjectLevelGUIDType guidType)
        {
            string parameterName = "Ifc" + guidType.ToString() + " GUID";
            ProjectInfo projectInfo = document.ProjectInformation;

            if (projectInfo != null)
            {
                string paramValue = null;
                ParameterUtil.GetStringValueFromElement(projectInfo.Id, parameterName, out paramValue);
                if ((paramValue != null) && (IsValidIFCGUID(paramValue)))
                    return paramValue;
            }

            string guid = ExporterIFCUtils.CreateProjectLevelGUID(document, guidType);
            if ((projectInfo != null) && ExporterCacheManager.ExportOptionsCache.GUIDOptions.StoreIFCGUID)
            {
                BuiltInParameter parameterId = BuiltInParameter.INVALID;
                switch (guidType)
                {
                    case IFCProjectLevelGUIDType.Building:
                        parameterId = BuiltInParameter.IFC_BUILDING_GUID;
                        break;
                    case IFCProjectLevelGUIDType.Project:
                        parameterId = BuiltInParameter.IFC_PROJECT_GUID;
                        break;
                    case IFCProjectLevelGUIDType.Site:
                        parameterId = BuiltInParameter.IFC_SITE_GUID;
                        break;
                }
                if (parameterId != BuiltInParameter.INVALID)
                    ExporterCacheManager.GUIDsToStoreCache[new KeyValuePair<Element, BuiltInParameter>(projectInfo, parameterId)] = guid;
            }
            return guid;
        }