Beispiel #1
0
        /// <summary>
        /// Creates or populates Revit elements based on the information contained in this class.
        /// </summary>
        /// <param name="doc">The document.</param>
        protected override void Create(Document doc)
        {
            base.Create(doc);

            IFCLocation.WarnIfFaraway(this);

            // IfcBuilding usually won't create an element, as it contains no geometry.
            // If it doesn't, use the ProjectInfo element in the document to store its parameters.
            if (CreatedElementId == ElementId.InvalidElementId)
            {
                CreatedElementId = Importer.TheCache.ProjectInformationId;
            }
        }
        /// <summary>
        /// Creates or populates Revit elements based on the information contained in this class.
        /// </summary>
        /// <param name="doc">The document.</param>
        protected override void Create(Document doc)
        {
            IFCLocation.WarnIfFaraway(this);

            // We may re-use the ActiveView Level and View, since we can't delete them.
            // We will consider that we "created" this level and view for creation metrics.
            Level level = Importer.TheCache.UseElementByGUID <Level>(doc, GlobalId);

            bool reusedLevel = false;
            bool foundLevel  = false;

            if (level == null)
            {
                if (ExistingLevelIdToReuse != ElementId.InvalidElementId)
                {
                    level = doc.GetElement(ExistingLevelIdToReuse) as Level;
                    Importer.TheCache.UseElement(level);
                    ExistingLevelIdToReuse = ElementId.InvalidElementId;
                    reusedLevel            = true;
                }
            }
            else
            {
                foundLevel = true;
            }

            double referenceElevation = GetReferenceElevation();
            double totalElevation     = Elevation + referenceElevation;

            if (level == null)
            {
                level = Level.Create(doc, totalElevation);
            }
            else
            {
                level.Elevation = totalElevation;
            }

            if (level != null)
            {
                CreatedElementId = level.Id;
            }

            if (CreatedElementId != ElementId.InvalidElementId)
            {
                if (!foundLevel)
                {
                    if (!reusedLevel)
                    {
                        ElementId viewPlanTypeId = IFCBuildingStorey.GetViewPlanTypeId(doc);
                        if (viewPlanTypeId != ElementId.InvalidElementId)
                        {
                            ViewPlan viewPlan = ViewPlan.Create(doc, viewPlanTypeId, CreatedElementId);
                            if (viewPlan != null)
                            {
                                CreatedViewId = viewPlan.Id;
                            }
                        }

                        if (CreatedViewId == ElementId.InvalidElementId)
                        {
                            Importer.TheLog.LogAssociatedCreationError(this, typeof(ViewPlan));
                        }
                    }
                    else
                    {
                        if (doc.ActiveView != null)
                        {
                            CreatedViewId = doc.ActiveView.Id;
                        }
                    }
                }
            }
            else
            {
                Importer.TheLog.LogCreationError(this, null, false);
            }

            TraverseSubElements(doc);
        }