Ejemplo n.º 1
0
        /// <summary>
        /// Calculates covering finish value.
        /// </summary>
        /// <remarks>
        /// True for structural columns, and false for architectural ones.
        /// </remarks>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="extrusionCreationData">
        /// The IFCExtrusionCreationData.
        /// </param>
        /// <param name="element">
        /// The element to calculate the value.
        /// </param>
        /// <param name="elementType">
        /// The element type.
        /// </param>
        /// <returns>
        /// True if the operation succeed, false otherwise.
        /// </returns>
        public override bool Calculate(ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            ParameterUtil.GetStringValueFromElementOrSymbol(element, "Finish", out m_Finish);
            if (!string.IsNullOrEmpty(m_Finish))
            {
                return(true);
            }

            if (element is Ceiling)
            {
                m_Finish = string.Empty;
                ISet <ElementId> matIds = HostObjectExporter.GetFinishMaterialIds(element as HostObject);
                foreach (ElementId matId in matIds)
                {
                    string materialName = NamingUtil.GetMaterialName(element.Document, matId);
                    if (string.IsNullOrWhiteSpace(materialName))
                    {
                        continue;
                    }
                    m_Finish += materialName + ";";
                }
                return(!string.IsNullOrEmpty(m_Finish));
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add the pair of component category name and material id pair
        /// </summary>
        /// <param name="materialId">The material id</param>
        public void AddRepresentationItemInfo(Document document, GraphicsStyle style, ElementId materialId, IFCAnyHandle repItem)
        {
            // Set with the proper category name if any
            string catName = style?.GraphicsStyleCategory?.Name;

            if (catName == null)
            {
                Material material = document.GetElement(materialId) as Material;
                catName = (material != null) ? NamingUtil.GetMaterialName(material) : "<Unnamed>"; // Default name to the Material name if not null or <Unnamed>
            }

            RepresentationItemInfo.Add(Tuple.Create(new MaterialConstituentInfo(catName, materialId), repItem));
            AddMaterial(materialId);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add the pair of component category name and material id pair
        /// This function also does AddMaterial(). Only use either AddMaterial if no component category needed, or this is Component Category is needed
        /// </summary>
        /// <param name="componentCategory">The Component Category name</param>
        /// <param name="materialId">The material id</param>
        public void AddRepresentationItemInfo(Document document, GeometryObject geomObject, ElementId materialId, IFCAnyHandle repItem)
        {
            GraphicsStyle graphicsStyle = document.GetElement(geomObject.GraphicsStyleId) as GraphicsStyle;
            string        catName       = null;

            if (graphicsStyle != null && graphicsStyle.GraphicsStyleCategory != null)
            {
                catName = graphicsStyle.GraphicsStyleCategory.Name;        // set with the proper category name if any
            }
            else
            {
                Material material = document.GetElement(materialId) as Material;
                catName = (material != null) ? NamingUtil.GetMaterialName(material) : "<Unnamed>"; // Default name to the Material name if not null or <Unnamed>
            }

            RepresentationItemInfo.Add(Tuple.Create(new MaterialConstituentInfo(catName, materialId), repItem));
            AddMaterial(materialId);
        }
Ejemplo n.º 4
0
        private static bool ExportCustomFabricSheet(FabricSheetExportConfig cfg)
        {
            if (cfg.Equals(null) || cfg.Sheet.IsBent)
            {
                return(false);
            }

            string                 guid         = GUIDUtil.CreateGUID(cfg.Sheet);
            IFCAnyHandle           ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
            HashSet <IFCAnyHandle> rebarHandles = new HashSet <IFCAnyHandle>();
            string                 matName      = NamingUtil.GetMaterialName(cfg.Doc, cfg.MaterialId);

            int ii = 0;

            do
            {
                WireDistributionDirection dir             = (WireDistributionDirection)ii;
                IList <Curve>             wireCenterlines = cfg.Sheet.GetWireCenterlines(dir);
                for (int jj = 0; jj < wireCenterlines.Count; jj++)
                {
                    double wireDiam = 0.0;

                    FabricWireItem wire = cfg.SheetType.GetWireItem(jj, dir);
                    if (cfg.Doc.GetElement(wire.WireType) is FabricWireType wireType)
                    {
                        wireDiam = UnitUtil.ScaleLength(wireType.WireDiameter);
                    }

                    IFCAnyHandle bodyItem = GeometryUtil.CreateSweptDiskSolid(cfg.ExporterIFC, cfg.File, wireCenterlines[jj], wireDiam / 2.0, null);
                    RepresentationUtil.CreateStyledItemAndAssign(cfg.File, cfg.Doc, cfg.MaterialId, bodyItem);

                    ISet <IFCAnyHandle> bodyItems = new HashSet <IFCAnyHandle> {
                        bodyItem
                    };
                    IFCAnyHandle shapeRep = null;
                    if (bodyItems.Count > 0)
                    {
                        shapeRep = RepresentationUtil.CreateAdvancedSweptSolidRep(cfg.ExporterIFC, cfg.Sheet, cfg.CategoryId,
                                                                                  cfg.ExporterIFC.Get3DContextHandle("Body"), bodyItems, null);
                    }
                    IList <IFCAnyHandle> shapeReps = new List <IFCAnyHandle>();
                    if (shapeRep != null)
                    {
                        shapeReps.Add(shapeRep);
                    }

                    IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(cfg.File, null, null, shapeReps);
                    IFCAnyHandle handle  = IFCInstanceExporter.CreateReinforcingBar(cfg.ExporterIFC, cfg.Sheet, guid, ExporterCacheManager.OwnerHistoryHandle,
                                                                                    cfg.PlacementSetter.LocalPlacement, prodRep, matName, wireDiam, 0, 0, IFCReinforcingBarRole.NotDefined, null);
                    IFCAnyHandleUtil.SetAttribute(handle, "ObjectType", "Generic");
                    CategoryUtil.CreateMaterialAssociation(cfg.ExporterIFC, handle, cfg.MaterialId);
                    rebarHandles.Add(handle);
                }
                ii++;
            }while (ii < 2);

            IFCAnyHandle assemblyInstanceHnd = IFCInstanceExporter.CreateElementAssembly(cfg.ExporterIFC, cfg.Sheet, guid,
                                                                                         ownerHistory, cfg.PlacementSetter.LocalPlacement, null, null, IFCElementAssemblyType.UserDefined);
            IFCExportInfoPair assemblyExportInfo = new IFCExportInfoPair(IFCEntityType.IfcElementAssembly);

            cfg.ProductWrapper.AddElement(cfg.Sheet, assemblyInstanceHnd, cfg.PlacementSetter.LevelInfo, null, true, assemblyExportInfo);
            ExporterCacheManager.AssemblyInstanceCache.RegisterAssemblyInstance(cfg.Sheet.Id, assemblyInstanceHnd);
            IFCInstanceExporter.CreateRelAggregates(cfg.File, guid, ownerHistory, null, null, assemblyInstanceHnd, rebarHandles);

            return(true);
        }