/// <summary> /// Creates a SweptSolid, Brep, SolidModel or SurfaceModel product definition shape representation, based on the geometry and IFC version. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="categoryId">The category id.</param> /// <param name="geometryElement">The geometry element.</param> /// <param name="bodyExporterOptions">The body exporter options.</param> /// <param name="extraReps">Extra representations (e.g. Axis, Boundary). May be null.</param> /// <param name="extrusionCreationData">The extrusion creation data.</param> /// <param name="bodyData">The body data.</param> /// <returns>The handle.</returns> public static IFCAnyHandle CreateAppropriateProductDefinitionShape(ExporterIFC exporterIFC, Element element, ElementId categoryId, GeometryElement geometryElement, BodyExporterOptions bodyExporterOptions, IList <IFCAnyHandle> extraReps, IFCExtrusionCreationData extrusionCreationData, out BodyData bodyData) { bodyData = null; SolidMeshGeometryInfo info = null; IList <GeometryObject> geometryList = new List <GeometryObject>(); if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x2) { info = GeometryUtil.GetSplitSolidMeshGeometry(geometryElement, Transform.Identity); IList <Mesh> meshes = info.GetMeshes(); if (meshes.Count == 0) { IList <Solid> solidList = info.GetSolids(); foreach (Solid solid in solidList) { geometryList.Add(solid); } } } if (geometryList.Count == 0) { geometryList.Add(geometryElement); } else { bodyExporterOptions.TryToExportAsExtrusion = true; } bodyData = BodyExporter.ExportBody(exporterIFC, element, categoryId, ElementId.InvalidElementId, geometryList, bodyExporterOptions, extrusionCreationData); IFCAnyHandle bodyRep = bodyData.RepresentationHnd; List <IFCAnyHandle> bodyReps = new List <IFCAnyHandle>(); if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep)) { if (extrusionCreationData != null) { extrusionCreationData.ClearOpenings(); } } else { bodyReps.Add(bodyRep); } if (extraReps != null) { foreach (IFCAnyHandle hnd in extraReps) { bodyReps.Add(hnd); } } Transform boundingBoxTrf = (bodyData.OffsetTransform != null) ? bodyData.OffsetTransform.Inverse : Transform.Identity; IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geometryElement, boundingBoxTrf); if (boundingBoxRep != null) { bodyReps.Add(boundingBoxRep); } if (bodyReps.Count == 0) { return(null); } return(IFCInstanceExporter.CreateProductDefinitionShape(exporterIFC.GetFile(), null, null, bodyReps)); }
/// <summary> /// Creates a SweptSolid, Brep, or Surface product definition shape representation, depending on the geoemtry and export version. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="categoryId">The category id.</param> /// <param name="geometryElement">The geometry element.</param> /// <param name="bodyExporterOptions">The body exporter options.</param> /// <param name="extraReps">Extra representations (e.g. Axis, Boundary). May be null.</param> /// <param name="extrusionCreationData">The extrusion creation data.</param> /// <param name="allowOffsetTransform">Allows local coordinate system to be placed close to geometry.</param> /// <returns>The handle.</returns> /// <remarks>allowOffsetTransform should only be set to true if no other associated geometry is going to be exported. Otherwise, /// there could be an offset between this geometry and the other, non-transformed, geometry.</remarks> public static IFCAnyHandle CreateAppropriateProductDefinitionShape(ExporterIFC exporterIFC, Element element, ElementId categoryId, GeometryElement geometryElement, BodyExporterOptions bodyExporterOptions, IList <IFCAnyHandle> extraReps, IFCExtrusionCreationData extrusionCreationData, bool allowOffsetTransform) { BodyData bodyData; BodyExporterOptions newBodyExporterOptions = new BodyExporterOptions(bodyExporterOptions); newBodyExporterOptions.AllowOffsetTransform = allowOffsetTransform; return(CreateAppropriateProductDefinitionShape(exporterIFC, element, categoryId, geometryElement, newBodyExporterOptions, extraReps, extrusionCreationData, out bodyData)); }
/// <summary> /// Creates a Brep product definition shape representation. /// </summary> /// <remarks> /// It will try to export the geometry as an extrusion if it is not exported as IFC 2x2 version. /// </remarks> /// <param name="application"> /// The Revit application object. /// </param> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="categoryId"> /// The category id. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="bodyExporterOptions"> /// The body exporter options. /// </param> /// <param name="extraReps"> /// Extra representations (e.g. Axis, Boundary). May be null. /// </param> /// <param name="extrusionCreationData"> /// The extrusion creation data. /// </param> /// <returns> /// The handle. /// </returns> public static IFCAnyHandle CreateBRepProductDefinitionShape(Autodesk.Revit.ApplicationServices.Application application, ExporterIFC exporterIFC, Element element, ElementId categoryId, GeometryElement geometryElement, BodyExporterOptions bodyExporterOptions, IList <IFCAnyHandle> extraReps, IFCExtrusionCreationData extrusionCreationData) { BodyData bodyData; return(CreateBRepProductDefinitionShape(application, exporterIFC, element, categoryId, geometryElement, bodyExporterOptions, extraReps, extrusionCreationData, out bodyData)); }
/// <summary> /// Creates a Brep product definition shape representation. /// </summary> /// <remarks> /// It will try to export the geometry as an extrusion if it is not exported as IFC 2x2 version. /// </remarks> /// <param name="application"> /// The Revit application object. /// </param> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="categoryId"> /// The category id. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="bodyExporterOptions"> /// The body exporter options. /// </param> /// <param name="extraReps"> /// Extra representations (e.g. Axis, Boundary). May be null. /// </param> /// <param name="extrusionCreationData"> /// The extrusion creation data. /// </param> /// <param name="bodyData"> /// The body data. /// </param> /// <returns> /// The handle. /// </returns> public static IFCAnyHandle CreateBRepProductDefinitionShape(Autodesk.Revit.ApplicationServices.Application application, ExporterIFC exporterIFC, Element element, ElementId categoryId, GeometryElement geometryElement, BodyExporterOptions bodyExporterOptions, IList <IFCAnyHandle> extraReps, IFCExtrusionCreationData extrusionCreationData, out BodyData bodyData) { SolidMeshGeometryInfo info = null; IList <GeometryObject> solids = new List <GeometryObject>(); if (!exporterIFC.ExportAs2x2) { info = GeometryUtil.GetSolidMeshGeometry(geometryElement, Transform.Identity); IList <Mesh> meshes = info.GetMeshes(); if (meshes.Count == 0) { IList <Solid> solidList = info.GetSolids(); foreach (Solid solid in solidList) { solids.Add(solid); } } } IFCAnyHandle ret = null; if (solids.Count == 0) { IList <GeometryObject> geometryList = new List <GeometryObject>(); geometryList.Add(geometryElement); ret = CreateBRepProductDefinitionShape(application, exporterIFC, element, categoryId, geometryList, extraReps, bodyExporterOptions, extrusionCreationData, out bodyData); } else { bodyExporterOptions.TryToExportAsExtrusion = true; ret = CreateBRepProductDefinitionShape(application, exporterIFC, element, categoryId, solids, extraReps, bodyExporterOptions, extrusionCreationData, out bodyData); } return(ret); }
/// <summary> /// Creates an opening from a solid. /// </summary> /// <param name="exporterIFC">The exporter.</param> /// <param name="hostObjHnd">The host object handle.</param> /// <param name="hostElement">The host element.</param> /// <param name="insertElement">The insert element.</param> /// <param name="openingGUID">The GUID for the opening, depending on how the opening is created.</param> /// <param name="solid">The solid.</param> /// <param name="scaledHostWidth">The scaled host width.</param> /// <param name="isRecess">True if it is recess.</param> /// <param name="extrusionCreationData">The extrusion creation data.</param> /// <param name="setter">The placement setter.</param> /// <param name="localWrapper">The product wrapper.</param> /// <returns>The created opening handle.</returns> static public IFCAnyHandle CreateOpening(ExporterIFC exporterIFC, IFCAnyHandle hostObjHnd, Element hostElement, Element insertElement, string openingGUID, Solid solid, double scaledHostWidth, bool isRecess, IFCExtrusionCreationData extrusionCreationData, PlacementSetter setter, ProductWrapper localWrapper) { IFCFile file = exporterIFC.GetFile(); ElementId catId = CategoryUtil.GetSafeCategoryId(insertElement); XYZ prepToWall; bool isLinearWall = GetOpeningDirection(hostElement, out prepToWall); if (isLinearWall) { extrusionCreationData.CustomAxis = prepToWall; extrusionCreationData.PossibleExtrusionAxes = IFCExtrusionAxes.TryCustom; } BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true); BodyData bodyData = BodyExporter.ExportBody(exporterIFC, insertElement, catId, ElementId.InvalidElementId, solid, bodyExporterOptions, extrusionCreationData); IFCAnyHandle openingRepHnd = bodyData.RepresentationHnd; if (IFCAnyHandleUtil.IsNullOrHasNoValue(openingRepHnd)) { extrusionCreationData.ClearOpenings(); return(null); } IList <IFCAnyHandle> representations = new List <IFCAnyHandle>(); representations.Add(openingRepHnd); IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations); IFCAnyHandle openingPlacement = extrusionCreationData.GetLocalPlacement(); IFCAnyHandle hostObjPlacementHnd = IFCAnyHandleUtil.GetObjectPlacement(hostObjHnd); Transform relTransform = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(openingPlacement, hostObjPlacementHnd); openingPlacement = ExporterUtil.CreateLocalPlacement(file, hostObjPlacementHnd, relTransform.Origin, relTransform.BasisZ, relTransform.BasisX); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); double scaledOpeningLength = extrusionCreationData.ScaledLength; string openingObjectType = "Opening"; if (!MathUtil.IsAlmostZero(scaledHostWidth) && !MathUtil.IsAlmostZero(scaledOpeningLength)) { openingObjectType = scaledOpeningLength < (scaledHostWidth - MathUtil.Eps()) ? "Recess" : "Opening"; } else { openingObjectType = isRecess ? "Recess" : "Opening"; } string openingName = NamingUtil.GetNameOverride(insertElement, null); if (string.IsNullOrEmpty(openingName)) { if (!IFCAnyHandleUtil.IsNullOrHasNoValue(hostObjHnd)) { openingName = IFCAnyHandleUtil.GetStringAttribute(hostObjHnd, "Name"); } else { openingName = NamingUtil.GetNameOverride(hostElement, NamingUtil.CreateIFCObjectName(exporterIFC, hostElement)); } } IFCAnyHandle openingHnd = IFCInstanceExporter.CreateOpeningElement(file, openingGUID, ownerHistory, openingName, null, openingObjectType, openingPlacement, prodRep, null); if (ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities) { PropertyUtil.CreateOpeningQuantities(exporterIFC, openingHnd, extrusionCreationData); } if (localWrapper != null) { Element elementForProperties = null; if (GUIDUtil.IsGUIDFor(insertElement, openingGUID)) { elementForProperties = insertElement; } localWrapper.AddElement(insertElement, openingHnd, setter, extrusionCreationData, true); } string voidGuid = GUIDUtil.CreateGUID(); IFCInstanceExporter.CreateRelVoidsElement(file, voidGuid, ownerHistory, null, null, hostObjHnd, openingHnd); return(openingHnd); }