本文整理汇总了C#中IFCExtrusionCreationData.GetLocalPlacement方法的典型用法代码示例。如果您正苦于以下问题:C# IFCExtrusionCreationData.GetLocalPlacement方法的具体用法?C# IFCExtrusionCreationData.GetLocalPlacement怎么用?C# IFCExtrusionCreationData.GetLocalPlacement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFCExtrusionCreationData
的用法示例。
在下文中一共展示了IFCExtrusionCreationData.GetLocalPlacement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportDuctLining
/// <summary>
/// Exports an element as a covering of type insulation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportDuctLining(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle ductLining = IFCInstanceExporter.CreateCovering(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, "Wrapping");
ExporterCacheManager.ElementToHandleCache.Register(element.Id, ductLining);
productWrapper.AddElement(element, ductLining, placementSetter.LevelInfo, ecData, true);
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
CategoryUtil.CreateMaterialAssociation(exporterIFC, ductLining, matId);
}
}
tr.Commit();
return true;
}
}
示例2: ExportDuctLining
/// <summary>
/// Exports an element as a covering of type insulation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportDuctLining(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.GetPlacement());
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle ductLining = IFCInstanceExporter.CreateCovering(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, IFCCoveringType.Wrapping);
productWrapper.AddElement(ductLining, placementSetter.GetLevelInfo(), ecData, LevelUtil.AssociateElementToLevel(element));
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
}
}
tr.Commit();
return true;
}
}
示例3: ExportBuildingElementProxy
/// <summary>
/// Exports an element as building element proxy.
/// </summary>
/// <remarks>
/// This function is called from the Export function, but can also be called directly if you do not
/// want CreateInternalPropertySets to be called.
/// </remarks>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>The handle if created, null otherwise.</returns>
public static IFCAnyHandle ExportBuildingElementProxy(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return null;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle buildingElementProxy = null;
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return null;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
buildingElementProxy = IFCInstanceExporter.CreateBuildingElementProxy(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, null);
productWrapper.AddElement(element, buildingElementProxy, placementSetter.LevelInfo, ecData, true);
}
tr.Commit();
}
}
return buildingElementProxy;
}
示例4: ExportBuildingElementProxy
/// <summary>
/// Exports an element as building element proxy.
/// </summary>
/// <remarks>
/// This function is called from the Export function, but can also be called directly if you do not
/// want CreateInternalPropertySets to be called.
/// </remarks>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The IFCProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportBuildingElementProxy(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, IFCProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.GetPlacement());
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateBRepProductDefinitionShape(element.Document.Application, exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = ExporterIFCUtils.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string objectType = exporterIFC.GetFamilyName();
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.CreateIFCElementId(element);
IFCAnyHandle buildingElementProxy = IFCInstanceExporter.CreateBuildingElementProxy(file, guid,
ownerHistory, objectType, null, objectType, localPlacement, representation, elementTag, Toolkit.IFCElementComposition.Element);
productWrapper.AddElement(buildingElementProxy, placementSetter.GetLevelInfo(), ecData, LevelUtil.AssociateElementToLevel(element));
}
tr.Commit();
return true;
}
}
}
示例5: ExportPile
/// <summary>
/// Exports an element to IfcPile.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="ifcEnumType">The string value represents the IFC type.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportPile(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
string ifcEnumType, ProductWrapper productWrapper)
{
// export parts or not
bool exportParts = PartExporter.CanExportParts(element);
if (exportParts && !PartExporter.CanExportElementInPartExport(element, element.Level.Id, false))
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(setter.GetPlacement());
IFCAnyHandle prodRep = null;
ElementId matId = ElementId.InvalidElementId;
if (!exportParts)
{
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
element, catId, geometryElement, bodyExporterOptions, null, ecData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
{
ecData.ClearOpenings();
return;
}
}
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string instanceTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
Toolkit.IFCPileType pileType = GetPileType(element, ifcEnumType);
IFCAnyHandle pile = IFCInstanceExporter.CreatePile(file, instanceGUID, exporterIFC.GetOwnerHistoryHandle(),
instanceName, instanceDescription, instanceObjectType, ecData.GetLocalPlacement(), prodRep, instanceTag, pileType, null);
if (exportParts)
{
PartExporter.ExportHostPart(exporterIFC, element, pile, productWrapper, setter, setter.GetPlacement(), null);
}
else
{
if (matId != ElementId.InvalidElementId)
{
CategoryUtil.CreateMaterialAssociation(element.Document, exporterIFC, pile, matId);
}
}
productWrapper.AddElement(pile, setter, ecData, LevelUtil.AssociateElementToLevel(element));
OpeningUtil.CreateOpeningsIfNecessary(pile, element, ecData, exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
}
}
tr.Commit();
}
}
示例6: CreateOpening
/// <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;
}
示例7: ExportRoofAsContainer
/// <summary>
/// Exports a roof as a container of multiple roof slabs. Returns the handle, if successful.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="ifcEnumType">The roof type.</param>
/// <param name="element">The roof element.</param>
/// <param name="geometry">The geometry of the element.</param>
/// <param name="productWrapper">The product wrapper.</param>
/// <returns>The roof handle.</returns>
public static IFCAnyHandle ExportRoofAsContainer(ExporterIFC exporterIFC, string ifcEnumType, Element element, GeometryElement geometry, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
if (!(element is ExtrusionRoof) && !(element is FootPrintRoof))
return null;
using (IFCTransaction transaction = new IFCTransaction(file))
{
using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
{
IFCAnyHandle localPlacement = setter.LocalPlacement;
RoofComponents roofComponents = null;
try
{
roofComponents = ExporterIFCUtils.GetRoofComponents(exporterIFC, element as RoofBase);
}
catch
{
return null;
}
if (roofComponents == null)
return null;
try
{
using (IFCExtrusionCreationData extrusionCreationData = new IFCExtrusionCreationData())
{
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
extrusionCreationData.SetLocalPlacement(localPlacement);
extrusionCreationData.ReuseLocalPlacement = true;
using (TransformSetter trfSetter = TransformSetter.Create())
{
IList<GeometryObject> geometryList = new List<GeometryObject>();
geometryList.Add(geometry);
trfSetter.InitializeFromBoundingBox(exporterIFC, geometryList, extrusionCreationData);
IFCAnyHandle prodRepHnd = null;
string elementGUID = GUIDUtil.CreateGUID(element);
string elementName = NamingUtil.GetIFCName(element);
string elementDescription = NamingUtil.GetDescriptionOverride(element, null);
string elementObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string elementId = NamingUtil.CreateIFCElementId(element);
string roofType = IFCValidateEntry.GetValidIFCType(element, ifcEnumType);
IFCAnyHandle roofHandle = IFCInstanceExporter.CreateRoof(file, elementGUID, ownerHistory, elementName, elementDescription,
elementObjectType, localPlacement, prodRepHnd, elementId, roofType);
IList<IFCAnyHandle> elementHandles = new List<IFCAnyHandle>();
elementHandles.Add(roofHandle);
//only thing supported right now.
XYZ extrusionDir = new XYZ(0, 0, 1);
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
IList<CurveLoop> roofCurveloops = roofComponents.GetCurveLoops();
IList<XYZ> planeDirs = roofComponents.GetPlaneDirections();
IList<XYZ> planeOrigins = roofComponents.GetPlaneOrigins();
IList<Face> loopFaces = roofComponents.GetLoopFaces();
double scaledDepth = roofComponents.ScaledDepth;
IList<double> areas = roofComponents.GetAreasOfCurveLoops();
IList<IFCAnyHandle> slabHandles = new List<IFCAnyHandle>();
using (IFCExtrusionCreationData slabExtrusionCreationData = new IFCExtrusionCreationData())
{
slabExtrusionCreationData.SetLocalPlacement(extrusionCreationData.GetLocalPlacement());
slabExtrusionCreationData.ReuseLocalPlacement = false;
slabExtrusionCreationData.ForceOffset = true;
for (int numLoop = 0; numLoop < roofCurveloops.Count; numLoop++)
{
trfSetter.InitializeFromBoundingBox(exporterIFC, geometryList, slabExtrusionCreationData);
Plane plane = new Plane(planeDirs[numLoop], planeOrigins[numLoop]);
IList<CurveLoop> curveLoops = new List<CurveLoop>();
curveLoops.Add(roofCurveloops[numLoop]);
double slope = Math.Abs(planeDirs[numLoop].Z);
double scaledExtrusionDepth = scaledDepth * slope;
IFCAnyHandle shapeRep = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, null, curveLoops, plane, extrusionDir, scaledExtrusionDepth);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(shapeRep))
return null;
ElementId matId = HostObjectExporter.GetFirstLayerMaterialId(element as HostObject);
BodyExporter.CreateSurfaceStyleForRepItem(exporterIFC, element.Document, shapeRep, matId);
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
bodyItems.Add(shapeRep);
shapeRep = RepresentationUtil.CreateSweptSolidRep(exporterIFC, element, catId, exporterIFC.Get3DContextHandle("Body"), bodyItems, null);
//.........这里部分代码省略.........
示例8: ExportFamilyInstanceAsMappedItem
//.........这里部分代码省略.........
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, IFCGeometryInfo, exportGeometry, curveOffset, false);
IList<IFCAnyHandle> curves = IFCGeometryInfo.GetCurves();
foreach (IFCAnyHandle curve in curves)
curveSet.Add(curve);
if (curveSet.Count > 0)
{
IFCAnyHandle contextOfItems2d = exporterIFC.Get2DContextHandle();
IFCAnyHandle curveRepresentationItem = IFCInstanceExporter.CreateGeometricSet(file, curveSet);
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
bodyItems.Add(curveRepresentationItem);
planRepresentation = RepresentationUtil.CreateGeometricSetRep(exporterIFC, familyInstance, categoryId, "Annotation",
contextOfItems2d, bodyItems);
}
}
}
}
}
if (doorWindowInfo != null)
{
typeInfo.StyleTransform = doorWindowTrf.Inverse;
}
else
{
if (!MathUtil.IsAlmostZero(extraOffset.DotProduct(extraOffset)))
{
Transform newTransform = typeInfo.StyleTransform;
XYZ newOrig = newTransform.Origin + extraOffset;
newTransform.Origin = newOrig;
typeInfo.StyleTransform = newTransform;
}
typeInfo.StyleTransform = ExporterIFCUtils.GetUnscaledTransform(exporterIFC, extraParams.GetLocalPlacement());
}
IFCAnyHandle origin = ExporterUtil.CreateAxis2Placement3D(file);
IFCAnyHandle repMap2dHnd = null;
IFCAnyHandle repMap3dHnd = IFCInstanceExporter.CreateRepresentationMap(file, origin, bodyRepresentation);
IList<IFCAnyHandle> repMapList = new List<IFCAnyHandle>();
repMapList.Add(repMap3dHnd);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(planRepresentation))
{
repMap2dHnd = IFCInstanceExporter.CreateRepresentationMap(file, origin, planRepresentation);
repMapList.Add(repMap2dHnd);
}
// for Door, Window
bool paramTakesPrecedence = false; // For Revit, this is currently always false.
bool sizeable = false;
// for many
HashSet<IFCAnyHandle> propertySets = new HashSet<IFCAnyHandle>();
string guid = GUIDUtil.CreateGUID(familySymbol);
string symId = NamingUtil.CreateIFCElementId(familySymbol);
// This covers many generic types. If we can't find it in the list here, do custom exports.
IFCAnyHandle typeStyle = FamilyExporterUtil.ExportGenericType(file, exportType, ifcEnumType, guid,
ownerHistory, objectType, null, null, propertySets, repMapList, symId, objectType,
familyInstance, familySymbol);
// Cover special cases not covered above.
if (IFCAnyHandleUtil.IsNullOrHasNoValue(typeStyle))
{
示例9: InitializeFromBoundingBox
/// <summary>
/// Initializes the transformation in the transform setter.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="geometryList">The set of geometry used to determine the bounding box.</param>
/// <param name="ecData">The extrusion creation data which contains the local placement.</param>
/// <returns>The transform corresponding to the movement, if any.</returns>
/// <remarks>This method will eventually be obsoleted by the InitializeFromBoundingBox/CreateLocalPlacementFromOffset pair below, which delays creating or updating the local placement
/// until we are certain we will use it, saving time and reducing wasted line numbers.</remarks>
public Transform InitializeFromBoundingBox(ExporterIFC exporterIFC, IList<GeometryObject> geometryList, IFCExtrusionCreationData ecData)
{
if (ecData == null)
return null;
Transform trf = Transform.Identity;
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(localPlacement))
{
IFCFile file = exporterIFC.GetFile();
BoundingBoxXYZ bbox = GeometryUtil.GetBBoxOfGeometries(geometryList);
// If the BBox passes through (0,0, 0), or no bbox, do nothing.
if (bbox == null ||
((bbox.Min.X < MathUtil.Eps() && bbox.Max.X > -MathUtil.Eps()) &&
(bbox.Min.Y < MathUtil.Eps() && bbox.Max.Y > -MathUtil.Eps()) &&
(bbox.Min.Z < MathUtil.Eps() && bbox.Max.Z > -MathUtil.Eps())))
{
if (!ecData.ReuseLocalPlacement)
ecData.SetLocalPlacement(ExporterUtil.CopyLocalPlacement(file, localPlacement));
return trf;
}
XYZ bboxMin = bbox.Min;
XYZ scaledOrig = UnitUtil.ScaleLength(bboxMin);
Transform scaledTrf = GeometryUtil.GetScaledTransform(exporterIFC);
XYZ lpOrig = scaledTrf.OfPoint(scaledOrig);
if (!ecData.AllowVerticalOffsetOfBReps)
lpOrig = new XYZ(lpOrig.X, lpOrig.Y, 0.0);
Transform scaledTrfInv = scaledTrf.Inverse;
XYZ scaledInvOrig = scaledTrfInv.OfPoint(XYZ.Zero);
XYZ unscaledInvOrig = UnitUtil.UnscaleLength(scaledInvOrig);
XYZ trfOrig = unscaledInvOrig - bboxMin;
if (!ecData.AllowVerticalOffsetOfBReps)
trfOrig = new XYZ(trfOrig.X, trfOrig.Y, 0.0);
if (!MathUtil.IsAlmostZero(trfOrig.DotProduct(trfOrig)))
{
Initialize(exporterIFC, trfOrig, XYZ.BasisX, XYZ.BasisY);
if (!ecData.ReuseLocalPlacement)
ecData.SetLocalPlacement(ExporterUtil.CreateLocalPlacement(file, localPlacement, lpOrig, null, null));
else
{
IFCAnyHandle relativePlacement = GeometryUtil.GetRelativePlacementFromLocalPlacement(localPlacement);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement))
{
IFCAnyHandle newRelativePlacement = ExporterUtil.CreateAxis(file, lpOrig, null, null);
GeometryUtil.SetRelativePlacement(localPlacement, newRelativePlacement);
}
else
{
IFCAnyHandle oldOriginHnd, zDirHnd, xDirHnd;
xDirHnd = IFCAnyHandleUtil.GetInstanceAttribute(relativePlacement, "RefDirection");
zDirHnd = IFCAnyHandleUtil.GetInstanceAttribute(relativePlacement, "Axis");
oldOriginHnd = IFCAnyHandleUtil.GetInstanceAttribute(relativePlacement, "Location");
bool trfSet = false;
XYZ xDir = XYZ.BasisX; XYZ zDir = XYZ.BasisZ; XYZ oldCoords = XYZ.Zero;
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(xDirHnd))
{
xDir = GeometryUtil.GetDirectionRatios(xDirHnd);
trfSet = true;
}
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(zDirHnd))
{
zDir = GeometryUtil.GetDirectionRatios(zDirHnd);
trfSet = true;
}
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(oldOriginHnd))
{
oldCoords = GeometryUtil.GetCoordinates(oldOriginHnd);
}
if (trfSet)
{
XYZ yDir = zDir.CrossProduct(xDir);
Transform relPlacementTrf = Transform.Identity;
relPlacementTrf.Origin = oldCoords; relPlacementTrf.BasisX = xDir;
relPlacementTrf.BasisY = yDir; relPlacementTrf.BasisZ = zDir;
lpOrig = relPlacementTrf.OfPoint(lpOrig);
}
else
lpOrig = oldCoords + lpOrig;
IFCAnyHandle newOriginHnd = ExporterUtil.CreateCartesianPoint(file, lpOrig);
IFCAnyHandleUtil.SetAttribute(relativePlacement, "Location", newOriginHnd);
//.........这里部分代码省略.........
示例10: ExportGenericSlab
/// <summary>
/// Exports a generic element as an IfcSlab.</summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="floor">The floor element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="ifcEnumType">The string value represents the IFC type.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if the floor is exported successfully, false otherwise.</returns>
public static void ExportGenericSlab(ExporterIFC exporterIFC, Element slabElement, GeometryElement geometryElement, string ifcEnumType,
ProductWrapper productWrapper)
{
if (geometryElement == null)
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCTransformSetter transformSetter = IFCTransformSetter.Create())
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, slabElement))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
bool exportParts = PartExporter.CanExportParts(slabElement);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle localPlacement = placementSetter.LocalPlacement;
IFCAnyHandle prodDefHnd = null;
bool isBRepSlabHnd = false;
if (!exportParts)
{
ecData.SetLocalPlacement(localPlacement);
ElementId catId = CategoryUtil.GetSafeCategoryId(slabElement);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
bodyExporterOptions.TessellationLevel = BodyExporter.GetTessellationLevel();
BodyData bodyData;
prodDefHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
slabElement, catId, geometryElement, bodyExporterOptions, null, ecData, out bodyData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodDefHnd))
{
ecData.ClearOpenings();
return;
}
isBRepSlabHnd = (bodyData.ShapeRepresentationType == ShapeRepresentationType.Brep);
}
// Create the slab from either the extrusion or the BRep information.
string ifcGUID = GUIDUtil.CreateGUID(slabElement);
string entityType = IFCValidateEntry.GetValidIFCType<IFCSlabType>(slabElement, ifcEnumType, "FLOOR");
string ifcName = NamingUtil.GetNameOverride(slabElement, NamingUtil.GetIFCName(slabElement));
string ifcDescription = NamingUtil.GetDescriptionOverride(slabElement, null);
string ifcObjectType = NamingUtil.GetObjectTypeOverride(slabElement, exporterIFC.GetFamilyName());
string ifcTag = NamingUtil.GetTagOverride(slabElement, NamingUtil.CreateIFCElementId(slabElement));
IFCAnyHandle slabHnd = IFCInstanceExporter.CreateSlab(file, ifcGUID, ownerHistory, ifcName,
ifcDescription, ifcObjectType, localPlacement, exportParts ? null : prodDefHnd,
ifcTag, entityType);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(slabHnd))
return;
if (exportParts)
PartExporter.ExportHostPart(exporterIFC, slabElement, slabHnd, productWrapper, placementSetter, localPlacement, null);
productWrapper.AddElement(slabElement, slabHnd, placementSetter, ecData, true);
if (!exportParts)
{
if (slabElement is HostObject)
{
HostObject hostObject = slabElement as HostObject;
HostObjectExporter.ExportHostObjectMaterials(exporterIFC, hostObject, slabHnd,
geometryElement, productWrapper, ElementId.InvalidElementId, Toolkit.IFCLayerSetDirection.Axis3, isBRepSlabHnd);
}
else if (slabElement is FamilyInstance)
{
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, slabElement);
Document doc = slabElement.Document;
CategoryUtil.CreateMaterialAssociation(exporterIFC, slabHnd, matId);
}
OpeningUtil.CreateOpeningsIfNecessary(slabHnd, slabElement, ecData, null,
exporterIFC, ecData.GetLocalPlacement(), placementSetter, productWrapper);
}
}
}
tr.Commit();
return;
}
}
}
示例11: ExportStairsAsContainer
//.........这里部分代码省略.........
geomSelectSet.Add(boundaryHnd);
HashSet<IFCAnyHandle> boundaryItems = new HashSet<IFCAnyHandle>();
boundaryItems.Add(IFCInstanceExporter.CreateGeometricSet(file, geomSelectSet));
IFCAnyHandle boundaryRep = RepresentationUtil.CreateGeometricSetRep(exporterIFC, run, categoryId, "FootPrint",
contextOfItemsFootPrint, boundaryItems);
reps.Add(boundaryRep);
}
CurveLoop walkingLine = run.GetStairsPath();
IFCAnyHandle walkingLineHnd = ExporterIFCUtils.CreateCurveFromCurveLoop(exporterIFC, walkingLine,
runBoundaryPlane, runBoundaryProjDir);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(walkingLineHnd))
{
HashSet<IFCAnyHandle> geomSelectSet = new HashSet<IFCAnyHandle>();
geomSelectSet.Add(walkingLineHnd);
HashSet<IFCAnyHandle> walkingLineItems = new HashSet<IFCAnyHandle>();
walkingLineItems.Add(IFCInstanceExporter.CreateGeometricSet(file, geomSelectSet));
IFCAnyHandle walkingLineRep = RepresentationUtil.CreateGeometricSetRep(exporterIFC, run, categoryId, "Axis",
contextOfItemsFootPrint, walkingLineItems);
reps.Add(walkingLineRep);
}
IFCAnyHandle representation = IFCInstanceExporter.CreateProductDefinitionShape(exporterIFC.GetFile(), null, null, reps);
string runGUID = ExporterIFCUtils.CreateGUID(run);
string origRunName = origStairName + " Run " + index;
string runName = NamingUtil.GetNameOverride(run, origRunName);
string runDescription = NamingUtil.GetDescriptionOverride(run, stairDescription);
string runObjectType = NamingUtil.GetObjectTypeOverride(run, stairObjectType);
IFCAnyHandle runLocalPlacement = ecData.GetLocalPlacement();
string runElementTag = NamingUtil.CreateIFCElementId(run);
IFCAnyHandle stairFlightHnd = IFCInstanceExporter.CreateStairFlight(file, runGUID, ownerHistory,
runName, runDescription, runObjectType, runLocalPlacement, representation, runElementTag,
run.ActualRisersNumber, run.ActualTreadsNumber, stair.ActualRiserHeight, stair.ActualTreadDepth);
componentHandles.Add(stairFlightHnd);
componentExtrusionData.Add(ecData);
productWrapper.AddElement(stairFlightHnd, placementSetter.GetLevelInfo(), ecData, false);
ExporterCacheManager.HandleToElementCache.Register(stairFlightHnd, run.Id);
}
}
// Get List of landings to export their geometry.
ICollection<ElementId> landingIds = stair.GetStairsLandings();
index = 0;
foreach (ElementId landingId in landingIds)
{
index++;
StairsLanding landing = doc.GetElement(landingId) as StairsLanding;
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.AllowVerticalOffsetOfBReps = false;
ecData.SetLocalPlacement(placementSetter.GetPlacement());
ecData.ReuseLocalPlacement = false;
GeometryElement landingGeometryElement = landing.get_Geometry(geomOptions);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
示例12: ExportRoof
/// <summary>
/// Exports a roof to IfcRoof.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="ifcEnumType">The roof type.</param>
/// <param name="roof">The roof element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportRoof(ExporterIFC exporterIFC, string ifcEnumType, Element roof, GeometryElement geometryElement,
ProductWrapper productWrapper)
{
if (roof == null || geometryElement == null)
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, roof, null, null, ExporterUtil.GetBaseLevelIdForElement(roof)))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
ecData.AreInnerRegionsOpenings = true;
ecData.SetLocalPlacement(placementSetter.GetPlacement());
ElementId categoryId = CategoryUtil.GetSafeCategoryId(roof);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
BodyData bodyData;
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, roof,
categoryId, geometryElement, bodyExporterOptions, null, ecData, out bodyData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return;
}
bool exportSlab = ecData.ScaledLength > MathUtil.Eps();
string guid = GUIDUtil.CreateGUID(roof);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string roofName = NamingUtil.GetNameOverride(roof, NamingUtil.GetIFCName(roof));
string roofDescription = NamingUtil.GetDescriptionOverride(roof, null);
string roofObjectType = NamingUtil.GetObjectTypeOverride(roof, NamingUtil.CreateIFCObjectName(exporterIFC, roof));
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(roof, NamingUtil.CreateIFCElementId(roof));
IFCRoofType roofType = GetIFCRoofType(ifcEnumType);
IFCAnyHandle roofHnd = IFCInstanceExporter.CreateRoof(file, guid, ownerHistory, roofName, roofDescription,
roofObjectType, localPlacement, exportSlab ? null : representation, elementTag, roofType);
productWrapper.AddElement(roof, roofHnd, placementSetter.GetLevelInfo(), ecData, true);
// will export its host object materials later if it is a roof
if (!(roof is RoofBase))
CategoryUtil.CreateMaterialAssociations(exporterIFC, roofHnd, bodyData.MaterialIds);
if (exportSlab)
{
string slabGUID = GUIDUtil.CreateSubElementGUID(roof, (int)IFCRoofSubElements.RoofSlabStart);
string slabName = roofName + ":1";
IFCAnyHandle slabLocalPlacementHnd = ExporterUtil.CopyLocalPlacement(file, localPlacement);
IFCAnyHandle slabHnd = IFCInstanceExporter.CreateSlab(file, slabGUID, ownerHistory, slabName,
roofDescription, roofObjectType, slabLocalPlacementHnd, representation, elementTag, IFCSlabType.Roof);
Transform offsetTransform = (bodyData != null) ? bodyData.OffsetTransform : Transform.Identity;
OpeningUtil.CreateOpeningsIfNecessary(slabHnd, roof, ecData, offsetTransform,
exporterIFC, slabLocalPlacementHnd, placementSetter, productWrapper);
ExporterUtil.RelateObject(exporterIFC, roofHnd, slabHnd);
productWrapper.AddElement(null, slabHnd, placementSetter.GetLevelInfo(), ecData, false);
CategoryUtil.CreateMaterialAssociations(exporterIFC, slabHnd, bodyData.MaterialIds);
}
}
tr.Commit();
}
}
}
示例13: ExportStairAsSingleGeometry
/// <summary>
/// Exports a staircase to IfcStair, without decomposing into separate runs and landings.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="ifcEnumType">The stairs type.</param>
/// <param name="stair">The stairs element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="numFlights">The number of flights for a multistory staircase.</param>
/// <param name="productWrapper">The IFCProductWrapper.</param>
public static void ExportStairAsSingleGeometry(ExporterIFC exporterIFC, string ifcEnumType, Element stair, GeometryElement geometryElement,
int numFlights, IFCProductWrapper productWrapper)
{
if (stair == null || geometryElement == null)
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, stair))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.GetPlacement());
ecData.ReuseLocalPlacement = false;
GeometryElement stairsGeom = GeometryUtil.GetOneLevelGeometryElement(geometryElement);
BodyData bodyData;
ElementId categoryId = CategoryUtil.GetSafeCategoryId(stair);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions();
IFCAnyHandle representation = RepresentationUtil.CreateBRepProductDefinitionShape(stair.Document.Application, exporterIFC,
stair, categoryId, stairsGeom, bodyExporterOptions, null, ecData, out bodyData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return;
}
string containedStairGuid = ExporterIFCUtils.CreateSubElementGUID(stair, (int)IFCStairSubElements.ContainedStair);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string origStairName = exporterIFC.GetName();
string stairName = NamingUtil.GetNameOverride(stair, origStairName);
string stairDescription = NamingUtil.GetDescriptionOverride(stair, null);
string stairObjectType = NamingUtil.GetObjectTypeOverride(stair, NamingUtil.CreateIFCObjectName(exporterIFC, stair));
IFCAnyHandle containedStairLocalPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.CreateIFCElementId(stair);
IFCStairType stairType = GetIFCStairType(ifcEnumType);
List<IFCAnyHandle> components = new List<IFCAnyHandle>();
IList<IFCExtrusionCreationData> componentExtrusionData = new List<IFCExtrusionCreationData>();
IFCAnyHandle containedStairHnd = IFCInstanceExporter.CreateStair(file, containedStairGuid, ownerHistory, stairName,
stairDescription, stairObjectType, containedStairLocalPlacement, representation, elementTag, stairType);
components.Add(containedStairHnd);
componentExtrusionData.Add(ecData);
//productWrapper.AddElement(containedStairHnd, placementSetter.GetLevelInfo(), ecData, false);
string guid = ExporterIFCUtils.CreateGUID(stair);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
IFCAnyHandle stairHnd = IFCInstanceExporter.CreateStair(file, guid, ownerHistory, stairName,
stairDescription, stairObjectType, localPlacement, null, elementTag, stairType);
productWrapper.AddElement(stairHnd, placementSetter.GetLevelInfo(), ecData, LevelUtil.AssociateElementToLevel(stair));
IFCAnyHandle emptyPlacement = null;
StairRampContainerInfo stairRampInfo = new StairRampContainerInfo(stairHnd, components, emptyPlacement);
ExporterCacheManager.StairRampContainerInfoCache.AddStairRampContainerInfo(stair.Id, stairRampInfo);
ExportMultistoryStair(exporterIFC, stair, numFlights, stairHnd, components, componentExtrusionData,
bodyData.MaterialIds, placementSetter, productWrapper);
}
tr.Commit();
}
}
}
示例14: ExportRoofAsParts
/// <summary>
/// Export the roof to IfcRoof containing its parts.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The roof element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportRoofAsParts(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element))
{
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle localPlacement = setter.GetPlacement();
using (IFCExtrusionCreationData extrusionCreationData = new IFCExtrusionCreationData())
{
extrusionCreationData.SetLocalPlacement(setter.GetPlacement());
extrusionCreationData.PossibleExtrusionAxes = IFCExtrusionAxes.TryXY;
IFCAnyHandle prodRepHnd = null;
string elementGUID = GUIDUtil.CreateGUID(element);
string elementName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string elementDescription = NamingUtil.GetDescriptionOverride(element, null);
string elementObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
//need to convert the string to enum
string ifcEnumType = CategoryUtil.GetIFCEnumTypeName(exporterIFC, element);
IFCAnyHandle roofHandle = IFCInstanceExporter.CreateRoof(file, elementGUID, ownerHistory, elementName, elementDescription, elementObjectType, localPlacement, prodRepHnd, elementTag, GetIFCRoofType(ifcEnumType));
// Export the parts
PartExporter.ExportHostPart(exporterIFC, element, roofHandle, productWrapper, setter, localPlacement, null);
productWrapper.AddElement(roofHandle, setter, extrusionCreationData, LevelUtil.AssociateElementToLevel(element));
OpeningUtil.CreateOpeningsIfNecessary(roofHandle, element, extrusionCreationData, exporterIFC, extrusionCreationData.GetLocalPlacement(), setter, productWrapper);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
}
transaction.Commit();
}
}
}
示例15: ExportCovering
//.........这里部分代码省略.........
{
using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
IFCAnyHandle prodRep = null;
if (!exportParts)
{
ecData.SetLocalPlacement(setter.LocalPlacement);
ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geomElem, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
{
ecData.ClearOpenings();
return;
}
}
// We will use the category of the element to set a default value for the covering.
string defaultCoveringEnumType = null;
if (categoryId == new ElementId(BuiltInCategory.OST_Ceilings))
defaultCoveringEnumType = "CEILING";
else if (categoryId == new ElementId(BuiltInCategory.OST_Floors))
defaultCoveringEnumType = "FLOORING";
else if (categoryId == new ElementId(BuiltInCategory.OST_Roofs))
defaultCoveringEnumType = "ROOFING";
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string instanceTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
string coveringType = IFCValidateEntry.GetValidIFCType(element, ifcEnumType, defaultCoveringEnumType);
IFCAnyHandle covering = IFCInstanceExporter.CreateCovering(file, instanceGUID, ExporterCacheManager.OwnerHistoryHandle,
instanceName, instanceDescription, instanceObjectType, setter.LocalPlacement, prodRep, instanceTag, coveringType);
if (exportParts)
{
PartExporter.ExportHostPart(exporterIFC, element, covering, productWrapper, setter, setter.LocalPlacement, null);
}
bool containInSpace = false;
IFCAnyHandle localPlacementToUse = setter.LocalPlacement;
// Ceiling containment in Space is generally required and not specific to any view
if (ExporterCacheManager.CeilingSpaceRelCache.ContainsKey(element.Id))
{
IList<ElementId> roomlist = ExporterCacheManager.CeilingSpaceRelCache[element.Id];
// Process Ceiling to be contained in a Space only when it is exactly bounding one Space
if (roomlist.Count == 1)
{
productWrapper.AddElement(element, covering, setter, null, false);
// Modify the Ceiling placement to be relative to the Space that it bounds
IFCAnyHandle roomPlacement = IFCAnyHandleUtil.GetObjectPlacement(ExporterCacheManager.SpaceInfoCache.FindSpaceHandle(roomlist[0]));
Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(roomPlacement, localPlacementToUse);
Transform inverseTrf = relTrf.Inverse;
IFCAnyHandle relLocalPlacement = ExporterUtil.CreateAxis2Placement3D(file, inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX);
IFCAnyHandleUtil.SetAttribute(localPlacementToUse, "PlacementRelTo", roomPlacement);
GeometryUtil.SetRelativePlacement(localPlacementToUse, relLocalPlacement);
ExporterCacheManager.SpaceInfoCache.RelateToSpace(roomlist[0], covering);
containInSpace = true;
}
}
// if not contained in Space, assign it to default containment in Level
if (!containInSpace)
productWrapper.AddElement(element, covering, setter, null, true);
if (!exportParts)
{
Ceiling ceiling = element as Ceiling;
if (ceiling != null)
{
HostObjectExporter.ExportHostObjectMaterials(exporterIFC, ceiling, covering,
geomElem, productWrapper, ElementId.InvalidElementId, Toolkit.IFCLayerSetDirection.Axis3, null);
}
else
{
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geomElem, exporterIFC, element);
CategoryUtil.CreateMaterialAssociation(exporterIFC, covering, matId);
}
}
OpeningUtil.CreateOpeningsIfNecessary(covering, element, ecData, null,
exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);
}
}
transaction.Commit();
}
}