예제 #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)
        {
            Units documentUnits = new Units(doc.DisplayUnitSystem == DisplayUnit.METRIC ?
                                            UnitSystem.Metric : UnitSystem.Imperial);

            foreach (IFCUnit unit in UnitsInContext)
            {
                if (!IFCUnit.IsNullOrInvalid(unit))
                {
                    try
                    {
                        FormatOptions formatOptions = new FormatOptions(unit.Unit);
                        formatOptions.SetSymbolTypeId(unit.Symbol);
                        documentUnits.SetFormatOptions(unit.Spec, formatOptions);
                    }
                    catch (Exception ex)
                    {
                        Importer.TheLog.LogError(unit.Id, ex.Message, false);
                    }
                }
            }
            doc.SetUnits(documentUnits);

            // We will randomize unused grid names so that they don't conflict with new entries with the same name.
            // This is only for relink.
            foreach (ElementId gridId in Importer.TheCache.GridNameToElementMap.Values)
            {
                Grid grid = doc.GetElement(gridId) as Grid;
                if (grid == null)
                {
                    continue;
                }

                // Note that new Guid() is useless - it creates a GUID of all 0s.
                grid.Name = Guid.NewGuid().ToString();
            }

            base.Create(doc);

            // IfcProject 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;
            }
        }