当前位置: 首页>>代码示例>>C#>>正文


C# ExporterIFC.SetBuilding方法代码示例

本文整理汇总了C#中ExporterIFC.SetBuilding方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.SetBuilding方法的具体用法?C# ExporterIFC.SetBuilding怎么用?C# ExporterIFC.SetBuilding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExporterIFC的用法示例。


在下文中一共展示了ExporterIFC.SetBuilding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BeginExport

        /// <summary>
        /// Initializes the common properties at the beginning of the export process.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="document">The document to export.</param>
        private void BeginExport(ExporterIFC exporterIFC, Document document, Autodesk.Revit.DB.View filterView)
        {
            // cache options
            ExportOptionsCache exportOptionsCache = ExportOptionsCache.Create(exporterIFC, filterView);
            ExporterCacheManager.ExportOptionsCache = exportOptionsCache;

            // Set language.
            Application app = document.Application;
            string pathName = document.PathName;
            LanguageType langType = LanguageType.Unknown;
            if (!String.IsNullOrEmpty(pathName))
            {
                try
                {
                    BasicFileInfo basicFileInfo = BasicFileInfo.Extract(pathName);
                    if (basicFileInfo != null)
                        langType = basicFileInfo.LanguageWhenSaved;
                }
                catch
                {
                }
            }
            if (langType == LanguageType.Unknown)
                langType = app.Language;
            ExporterCacheManager.LanguageType = langType;

            ElementFilteringUtil.InitCategoryVisibilityCache();

            ExporterCacheManager.Document = document;
            String writeIFCExportedElementsVar = Environment.GetEnvironmentVariable("WriteIFCExportedElements");
            if (writeIFCExportedElementsVar != null && writeIFCExportedElementsVar.Length > 0)
            {
                m_Writer = new StreamWriter(@"c:\ifc-output-filters.txt");
            }

            IFCFileModelOptions modelOptions = CreateIFCFileModelOptions(exporterIFC);

            m_IfcFile = IFCFile.Create(modelOptions);
            exporterIFC.SetFile(m_IfcFile);

            //init common properties
            InitializePropertySets(ExporterCacheManager.ExportOptionsCache.FileVersion);
            InitializeQuantities(ExporterCacheManager.ExportOptionsCache.FileVersion);

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                // create building
                IFCAnyHandle applicationHandle = CreateApplicationInformation(file, document);

                CreateGlobalCartesianOrigin(exporterIFC);
                CreateGlobalDirection(exporterIFC);
                CreateGlobalDirection2D(exporterIFC);

                // Start out relative to nothing, but replace with site later.
                IFCAnyHandle relativePlacement = ExporterUtil.CreateAxis2Placement3D(file);
                IFCAnyHandle buildingPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement);

                CreateProject(exporterIFC, document, applicationHandle);

                IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
                ProjectInfo projInfo = document.ProjectInformation;
              
                string buildingName = String.Empty;
                if (projInfo != null)
                {
                    try
                    {
                        buildingName = projInfo.BuildingName;
                    }
                    catch (Autodesk.Revit.Exceptions.InvalidOperationException)
                    {
                    }
                }
                
                IFCAnyHandle buildingAddress = CreateIFCAddress(file, document, projInfo);

                IFCAnyHandle buildingHandle = IFCInstanceExporter.CreateBuilding(file,
                    GUIDUtil.CreateProjectLevelGUID(document, IFCProjectLevelGUIDType.Building),
                    ownerHistory, buildingName, null, null, buildingPlacement, null, buildingName,
                    Toolkit.IFCElementComposition.Element, null, null, buildingAddress);
                exporterIFC.SetBuilding(buildingHandle);

                // create levels
                List<Level> levels = LevelUtil.FindAllLevels(document);

                bool exportAllLevels = true;
                for (int ii = 0; ii < levels.Count && exportAllLevels; ii++)
                {
                    Level level = levels[ii];
                    Parameter isBuildingStorey = level.get_Parameter(BuiltInParameter.LEVEL_IS_BUILDING_STORY);
                    if (isBuildingStorey == null || (isBuildingStorey.AsInteger() != 0))
                    {
                        exportAllLevels = false;
                        break;
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:Exporter.cs

示例2: BeginExport

        /// <summary>
        /// Initializes the common properties at the beginning of the export process.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="document">The document to export.</param>
        private void BeginExport(ExporterIFC exporterIFC, Document document)
        {
            ExporterCacheManager.Document = document;
            String writeIFCExportedElementsVar = Environment.GetEnvironmentVariable("WriteIFCExportedElements");
            if (writeIFCExportedElementsVar != null && writeIFCExportedElementsVar.Length > 0)
            {
                m_Writer = new StreamWriter(@"c:\ifc-output-filters.txt");
            }

            IFCFileModelOptions modelOptions = new IFCFileModelOptions();
            if (exporterIFC.ExportAs2x2)
            {
                modelOptions.SchemaFile = Path.Combine(ExporterUtil.RevitProgramPath, "EDM\\IFC2X2_ADD1.exp");
                modelOptions.SchemaName = "IFC2x2_FINAL";
            }
            else
            {
                modelOptions.SchemaFile = Path.Combine(ExporterUtil.RevitProgramPath, "EDM\\IFC2X3_TC1.exp");
                modelOptions.SchemaName = "IFC2x3";
            }

            m_IfcFile = IFCFile.Create(modelOptions);
            exporterIFC.SetFile(m_IfcFile);

            //init common properties
            ExporterInitializer.InitPropertySets(ExporterCacheManager.ExportOptionsCache.FileVersion);
            ExporterInitializer.InitQuantities(ExporterCacheManager.ExportOptionsCache.FileVersion, ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities);

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                // create building
                IFCAnyHandle applicationHandle = CreateApplicationInformation(file, document.Application);

                CreateGlobalCartesianOrigin(exporterIFC);
                CreateGlobalDirection(exporterIFC);
                CreateGlobalDirection2D(exporterIFC);

                IFCAnyHandle units = CreateDefaultUnits(exporterIFC, document);

                // Start out relative to nothing, but replace with site later.
                IFCAnyHandle relativePlacement = ExporterUtil.CreateAxis2Placement3D(file);
                IFCAnyHandle buildingPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement);

                HashSet<IFCAnyHandle> repContexts = CreateContextInformation(exporterIFC, document);
                IFCAnyHandle ownerHistory = CreateGenericOwnerHistory(exporterIFC, document, applicationHandle);
                exporterIFC.SetOwnerHistoryHandle(ownerHistory);

                IFCAnyHandle projectHandle = IFCInstanceExporter.CreateProject(file,
                    ExporterIFCUtils.CreateProjectLevelGUID(document, IFCProjectLevelGUIDType.Project), ownerHistory,
                    null, null, null, null, null, repContexts, units);
                exporterIFC.SetProject(projectHandle);

                ProjectInfo projInfo = document.ProjectInformation;
                string projectAddress = projInfo != null ? projInfo.Address : String.Empty;
                SiteLocation siteLoc = document.ActiveProjectLocation.SiteLocation;
                string location = siteLoc != null ? siteLoc.PlaceName : String.Empty;

                if (projectAddress == null)
                    projectAddress = String.Empty;
                if (location == null)
                    location = String.Empty;

                IFCAnyHandle buildingAddress = CreateIFCAddress(file, projectAddress, location);

                string buildingName = String.Empty;
                if (projInfo != null)
                {
                    try
                    {
                        buildingName = projInfo.BuildingName;
                    }
                    catch (Autodesk.Revit.Exceptions.InvalidOperationException)
                    {
                    }
                }

                IFCAnyHandle buildingHandle = IFCInstanceExporter.CreateBuilding(file,
                    ExporterIFCUtils.CreateProjectLevelGUID(document, IFCProjectLevelGUIDType.Building),
                    ownerHistory, buildingName, null, null, buildingPlacement, null, buildingName,
                    Toolkit.IFCElementComposition.Element, null, null, buildingAddress);
                exporterIFC.SetBuilding(buildingHandle);

                // create levels
                List<Level> levels = LevelUtil.FindAllLevels(document);

                bool exportAllLevels = true;
                for (int ii = 0; ii < levels.Count && exportAllLevels; ii++)
                {
                    Level level = levels[ii];
                    Parameter isBuildingStorey = level.get_Parameter(BuiltInParameter.LEVEL_IS_BUILDING_STORY);
                    if (isBuildingStorey == null || (isBuildingStorey.AsInteger() != 0))
                    {
                        exportAllLevels = false;
                        break;
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:BIM-IFC,代码行数:101,代码来源:Exporter.cs


注:本文中的ExporterIFC.SetBuilding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。