本文整理汇总了C#中ExporterIFC.GetLevelInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.GetLevelInfo方法的具体用法?C# ExporterIFC.GetLevelInfo怎么用?C# ExporterIFC.GetLevelInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExporterIFC
的用法示例。
在下文中一共展示了ExporterIFC.GetLevelInfo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RedirectDescription
/// <summary>
/// Finds the spatial element to its associated level.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="element">
/// The element.
/// </param>
/// <returns>
/// The handle.
/// </returns>
public override IFCAnyHandle RedirectDescription(ExporterIFC exporterIFC, Element element)
{
SpatialElement spatialElem = element as SpatialElement;
if (spatialElem != null)
{
ElementId levelId = spatialElem.LevelId;
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(levelId);
if (levelInfo != null)
return levelInfo.GetBuildingStorey();
}
return null;
}
示例2: ExportFamilyInstanceAsMappedItem
//.........这里部分代码省略.........
// 1. We are exporting part of a column or in-place wall (range != null), OR
// 2. We are using the instance's copy of the geometry (that it, it has unique geometry), OR
// 3. We haven't already created the type.
bool creatingType = ((range != null) || useInstanceGeometry || !found);
if (creatingType)
{
IFCAnyHandle bodyRepresentation = null;
IFCAnyHandle planRepresentation = null;
// If we are using the instance geometry, ignore the transformation.
if (useInstanceGeometry)
trf = Transform.Identity;
// TODO: this code to be removed by ExtrusionAnalyzer code.
if (trySpecialColumnCreation)
{
XYZ rangeOffset = trf.Origin;
IFCFamilyInstanceExtrusionExportResults results;
results = ExporterIFCUtils.ExportFamilyInstanceAsExtrusion(exporterIFC, familyInstance, useInstanceGeometry, range, overrideLevelId, extraParams);
bodyRepresentation = results.GetExtrusionHandle();
extraOffset = results.ExtraOffset;
cutPairOpeningsForColumns = results.GetCutPairOpenings();
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRepresentation))
{
typeInfo.MaterialIds.Add(results.MaterialId);
// add in level for real columns, not in-place ones.
Element actualLevel =
(overrideLevelId == ElementId.InvalidElementId) ? familyInstance.Level : doc.GetElement(overrideLevelId);
if (actualLevel != null)
{
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(actualLevel.Id);
double nonStoryLevelOffset = LevelUtil.GetNonStoryLevelOffsetIfAny(exporterIFC, actualLevel as Level);
if (range != null)
{
rangeOffset = new XYZ(rangeOffset.X, rangeOffset.Y, levelInfo.Elevation + nonStoryLevelOffset);
}
}
}
rangeOffset += extraOffset;
trf.Origin = rangeOffset;
}
IFCAnyHandle dummyPlacement = null;
if (doorWindowInfo != null)
{
doorWindowTrf = ExporterIFCUtils.GetTransformForDoorOrWindow(familyInstance, familySymbol, doorWindowInfo);
}
else
{
dummyPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, ExporterUtil.CreateAxis2Placement3D(file));
extraParams.SetLocalPlacement(dummyPlacement);
}
bool needToCreate2d = ExporterCacheManager.ExportOptionsCache.ExportAnnotations;
bool needToCreate3d = IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRepresentation);
if (needToCreate2d || needToCreate3d)
{
using (IFCTransformSetter trfSetter = IFCTransformSetter.Create())
{
if (doorWindowInfo != null)
{
示例3: ExportSpatialElement
/// <summary>
/// Exports spatial elements, including rooms, areas and spaces. 1st level space boundaries.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="spatialElement">
/// The spatial element.
/// </param>
/// <param name="productWrapper">
/// The ProductWrapper.
/// </param>
public static void ExportSpatialElement(ExporterIFC exporterIFC, SpatialElement spatialElement, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, spatialElement, null, null))
{
SpatialElementGeometryResults spatialElemGeomResult = null;
if (!CreateIFCSpace(exporterIFC, spatialElement, productWrapper, setter, out spatialElemGeomResult))
return;
bool isArea = (spatialElement is Area);
// Do not create boundary information for areas.
if (!isArea && (ExporterCacheManager.ExportOptionsCache.SpaceBoundaryLevel == 1))
{
Document document = spatialElement.Document;
ElementId levelId = spatialElement.LevelId;
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(levelId);
double baseHeightNonScaled = (levelInfo != null) ? levelInfo.Elevation : 0.0;
try
{
// This can throw an exception. If it does, continue to export element without boundary information.
// We will re-use the previously generated value, if we have it.
// TODO: warn user.
if (spatialElemGeomResult == null)
spatialElemGeomResult = s_SpatialElementGeometryCalculator.CalculateSpatialElementGeometry(spatialElement);
Solid spatialElemGeomSolid = spatialElemGeomResult.GetGeometry();
FaceArray faces = spatialElemGeomSolid.Faces;
foreach (Face face in faces)
{
IList<SpatialElementBoundarySubface> spatialElemBoundarySubfaces = spatialElemGeomResult.GetBoundaryFaceInfo(face);
foreach (SpatialElementBoundarySubface spatialElemBSubface in spatialElemBoundarySubfaces)
{
if (spatialElemBSubface.SubfaceType == SubfaceType.Side)
continue;
if (spatialElemBSubface.GetSubface() == null)
continue;
ElementId elemId = spatialElemBSubface.SpatialBoundaryElement.LinkInstanceId;
if (elemId == ElementId.InvalidElementId)
{
elemId = spatialElemBSubface.SpatialBoundaryElement.HostElementId;
}
Element boundingElement = document.GetElement(elemId);
if (boundingElement == null)
continue;
bool isObjectExt = CategoryUtil.IsElementExternal(boundingElement);
IFCGeometryInfo info = IFCGeometryInfo.CreateSurfaceGeometryInfo(spatialElement.Document.Application.VertexTolerance);
Face subFace = spatialElemBSubface.GetSubface();
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, subFace, XYZ.Zero, false);
foreach (IFCAnyHandle surfaceHnd in info.GetSurfaces())
{
IFCAnyHandle connectionGeometry = IFCInstanceExporter.CreateConnectionSurfaceGeometry(file, surfaceHnd, null);
SpaceBoundary spaceBoundary = new SpaceBoundary(spatialElement.Id, boundingElement.Id, setter.LevelId, connectionGeometry, IFCPhysicalOrVirtual.Physical,
isObjectExt ? IFCInternalOrExternal.External : IFCInternalOrExternal.Internal);
if (!ProcessIFCSpaceBoundary(exporterIFC, spaceBoundary, file))
ExporterCacheManager.SpaceBoundaryCache.Add(spaceBoundary);
}
}
}
}
catch
{
}
IList<IList<BoundarySegment>> roomBoundaries = spatialElement.GetBoundarySegments(GetSpatialElementBoundaryOptions(spatialElement));
double scaledRoomHeight = GetScaledHeight(spatialElement, levelId, levelInfo);
double unscaledHeight = UnitUtil.UnscaleLength(scaledRoomHeight);
Plane xyPlane = new Plane(XYZ.BasisZ, XYZ.Zero);
foreach (IList<BoundarySegment> roomBoundaryList in roomBoundaries)
{
foreach (BoundarySegment roomBoundary in roomBoundaryList)
{
Element boundingElement = roomBoundary.Element;
//.........这里部分代码省略.........
示例4: commonInit
/// <summary>
/// Attempt to determine the local placement of the element based on the element type and initial input.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC class.</param>
/// <param name="elem">The element being exported.</param>
/// <param name="familyTrf">The optional family transform.</param>
/// <param name="orientationTrf">The optional orientation of the element based on IFC standards or agreements.</param>
/// <param name="overrideLevelId">The optional level to place the element, to be used instead of heuristics.</param>
private void commonInit(ExporterIFC exporterIFC, Element elem, Transform familyTrf, Transform orientationTrf, ElementId overrideLevelId)
{
ExporterIFC = exporterIFC;
// Convert null value to InvalidElementId.
if (overrideLevelId == null)
overrideLevelId = ElementId.InvalidElementId;
Document doc = elem.Document;
Element hostElem = elem;
ElementId elemId = elem.Id;
ElementId newLevelId = overrideLevelId;
bool useOverrideOrigin = false;
XYZ overrideOrigin = XYZ.Zero;
IDictionary<ElementId, IFCLevelInfo> levelInfos = exporterIFC.GetLevelInfos();
if (overrideLevelId == ElementId.InvalidElementId)
{
if (familyTrf == null)
{
// Override for CurveElems -- base level calculation on origin of sketch Plane.
if (elem is CurveElement)
{
SketchPlane sketchPlane = (elem as CurveElement).SketchPlane;
if (sketchPlane != null)
{
useOverrideOrigin = true;
overrideOrigin = sketchPlane.GetPlane().Origin;
}
}
else
{
ElementId hostElemId = ElementId.InvalidElementId;
// a bit of a hack. If we have a railing, we want it to have the same level base as its host Stair (because of
// the way the stairs place railings and stair flights together).
if (elem is Railing)
{
hostElemId = (elem as Railing).HostId;
}
else if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Assemblies)
{
hostElemId = elem.AssemblyInstanceId;
}
if (hostElemId != ElementId.InvalidElementId)
{
hostElem = doc.GetElement(hostElemId);
}
newLevelId = hostElem != null ? hostElem.LevelId : ElementId.InvalidElementId;
if (newLevelId == ElementId.InvalidElementId)
{
ExporterIFCUtils.GetLevelIdByHeight(exporterIFC, hostElem);
}
}
}
// todo: store.
double bottomHeight = double.MaxValue;
ElementId bottomLevelId = ElementId.InvalidElementId;
if ((newLevelId == ElementId.InvalidElementId) || orientationTrf != null)
{
// if we have a trf, it might geometrically push the instance to a new level. Check that case.
// actually, we should ALWAYS check the bbox vs the settings
newLevelId = ElementId.InvalidElementId;
XYZ originToUse = XYZ.Zero;
bool originIsValid = useOverrideOrigin;
if (useOverrideOrigin)
{
originToUse = overrideOrigin;
}
else
{
BoundingBoxXYZ bbox = elem.get_BoundingBox(null);
if (bbox != null)
{
originToUse = bbox.Min;
originIsValid = true;
}
else if (hostElem.Id != elemId)
{
bbox = hostElem.get_BoundingBox(null);
if (bbox != null)
{
originToUse = bbox.Min;
originIsValid = true;
}
}
//.........这里部分代码省略.........
示例5: CreateIFCSpace
/// <summary>
/// Creates IFC room/space/area item, not include boundaries.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="spatialElement">The spatial element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <param name="setter">The PlacementSetter.</param>
/// <returns>True if created successfully, false otherwise.</returns>
static bool CreateIFCSpace(ExporterIFC exporterIFC, SpatialElement spatialElement, ProductWrapper productWrapper,
PlacementSetter setter, out SpatialElementGeometryResults results)
{
results = null;
IList<CurveLoop> curveLoops = null;
try
{
// Avoid throwing for a spatial element with no location.
if (spatialElement.Location == null)
return false;
SpatialElementBoundaryOptions options = GetSpatialElementBoundaryOptions(spatialElement);
curveLoops = ExporterIFCUtils.GetRoomBoundaryAsCurveLoopArray(spatialElement, options, true);
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
//Some spatial elements are not placed that have no boundary loops. Don't export them.
return false;
}
Autodesk.Revit.DB.Document document = spatialElement.Document;
ElementId levelId = spatialElement.LevelId;
ElementId catId = spatialElement.Category != null ? spatialElement.Category.Id : ElementId.InvalidElementId;
double dArea = 0.0;
if (ParameterUtil.GetDoubleValueFromElement(spatialElement, BuiltInParameter.ROOM_AREA, out dArea) != null)
dArea = UnitUtil.ScaleArea(dArea);
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(levelId);
string strSpaceNumber = null;
string strSpaceName = null;
string strSpaceDesc = null;
if (ParameterUtil.GetStringValueFromElement(spatialElement, BuiltInParameter.ROOM_NUMBER, out strSpaceNumber) == null)
strSpaceNumber = null;
if (ParameterUtil.GetStringValueFromElement(spatialElement, BuiltInParameter.ROOM_NAME, out strSpaceName) == null)
strSpaceName = null;
if (ParameterUtil.GetStringValueFromElement(spatialElement, BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS, out strSpaceDesc) == null)
strSpaceDesc = null;
string name = strSpaceNumber;
string longName = strSpaceName;
string desc = strSpaceDesc;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle localPlacement = setter.LocalPlacement;
ElementType elemType = document.GetElement(spatialElement.GetTypeId()) as ElementType;
IFCInternalOrExternal internalOrExternal = CategoryUtil.IsElementExternal(spatialElement) ? IFCInternalOrExternal.External : IFCInternalOrExternal.Internal;
double scaledRoomHeight = GetScaledHeight(spatialElement, levelId, levelInfo);
if (scaledRoomHeight <= 0.0)
return false;
double bottomOffset;
ParameterUtil.GetDoubleValueFromElement(spatialElement, BuiltInParameter.ROOM_LOWER_OFFSET, out bottomOffset);
double elevation = (levelInfo != null) ? levelInfo.Elevation : 0.0;
XYZ zDir = new XYZ(0, 0, 1);
XYZ orig = new XYZ(0, 0, elevation + bottomOffset);
Plane plane = new Plane(zDir, orig); // room calculated as level offset.
GeometryElement geomElem = null;
bool isArea = (spatialElement is Area);
Area spatialElementAsArea = isArea ? (spatialElement as Area) : null;
if (spatialElement is Autodesk.Revit.DB.Architecture.Room)
{
Autodesk.Revit.DB.Architecture.Room room = spatialElement as Autodesk.Revit.DB.Architecture.Room;
geomElem = room.ClosedShell;
}
else if (spatialElement is Autodesk.Revit.DB.Mechanical.Space)
{
Autodesk.Revit.DB.Mechanical.Space space = spatialElement as Autodesk.Revit.DB.Mechanical.Space;
geomElem = space.ClosedShell;
}
else if (isArea)
{
Options geomOptions = GeometryUtil.GetIFCExportGeometryOptions();
geomElem = spatialElementAsArea.get_Geometry(geomOptions);
}
IFCAnyHandle spaceHnd = null;
string spatialElementName = null;
using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
{
//.........这里部分代码省略.........
示例6: CreateIFCSpace
/// <summary>
/// Creates IFC room/space/area item, not include boundaries.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="spatialElement">
/// The spatial element.
/// </param>
/// <param name="productWrapper">
/// The ProductWrapper.
/// </param>
/// <param name="setter">
/// The IFCPlacementSetter.
/// </param>
/// <returns>
/// True if created successfully, false otherwise.
/// </returns>
static bool CreateIFCSpace(ExporterIFC exporterIFC, SpatialElement spatialElement, ProductWrapper productWrapper, IFCPlacementSetter setter)
{
IList<CurveLoop> curveLoops = null;
try
{
SpatialElementBoundaryOptions options = ExporterIFCUtils.GetSpatialElementBoundaryOptions(exporterIFC, spatialElement);
curveLoops = ExporterIFCUtils.GetRoomBoundaryAsCurveLoopArray(spatialElement, options, true);
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
//Some spatial elements are not placed that have no boundary loops. Don't export them.
return false;
}
Autodesk.Revit.DB.Document document = spatialElement.Document;
ElementId levelId = spatialElement.Level != null ? spatialElement.Level.Id : ElementId.InvalidElementId;
double scale = exporterIFC.LinearScale;
ElementId catId = spatialElement.Category != null ? spatialElement.Category.Id : ElementId.InvalidElementId;
double dArea = 0.0;
if (ParameterUtil.GetDoubleValueFromElement(spatialElement, BuiltInParameter.ROOM_AREA, out dArea))
dArea *= (scale * scale);
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(levelId);
string strSpaceNumber = null;
string strSpaceName = null;
string strSpaceDesc = null;
bool isArea = spatialElement is Area;
if (!isArea)
{
if (!ParameterUtil.GetStringValueFromElement(spatialElement, BuiltInParameter.ROOM_NUMBER, out strSpaceNumber))
strSpaceNumber = null;
if (!ParameterUtil.GetStringValueFromElement(spatialElement, BuiltInParameter.ROOM_NAME, out strSpaceName))
strSpaceName = null;
if (!ParameterUtil.GetStringValueFromElement(spatialElement, BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS, out strSpaceDesc))
strSpaceDesc = null;
}
else
{
// Default to true to preserve previous behavior.
bool? exportGSADesignGrossArea = ExporterCacheManager.ExportOptionsCache.ExportGSAGrossDesignArea;
if (!exportGSADesignGrossArea.HasValue || exportGSADesignGrossArea.Value)
{
Element level = document.GetElement(levelId);
if (level != null)
{
strSpaceNumber = level.Name + " GSA Design Gross Area";
}
}
}
string name = strSpaceNumber;
string longName = strSpaceName;
string desc = strSpaceDesc;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle localPlacement = setter.GetPlacement();
ElementType elemType = document.GetElement(spatialElement.GetTypeId()) as ElementType;
IFCInternalOrExternal internalOrExternal = CategoryUtil.IsElementExternal(spatialElement, true) ? IFCInternalOrExternal.External : IFCInternalOrExternal.Internal;
double roomHeight = 0.0;
roomHeight = GetHeight(spatialElement, scale, levelId, levelInfo);
if (roomHeight <= 0.0)
return false;
double bottomOffset;
ParameterUtil.GetDoubleValueFromElement(spatialElement, BuiltInParameter.ROOM_LOWER_OFFSET, out bottomOffset);
XYZ zDir = new XYZ(0, 0, 1);
XYZ orig = new XYZ(0, 0, levelInfo.Elevation + bottomOffset);
Plane plane = new Plane(zDir, orig); // room calculated as level offset.
GeometryElement geomElem = null;
if (spatialElement is Autodesk.Revit.DB.Architecture.Room)
//.........这里部分代码省略.........
示例7: CreateIFCSpace
/// <summary>
/// Create IFC room/space/area item, not include boundaries.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="spatialElement">
/// The spatial element.
/// </param>
/// <param name="productWrapper">
/// The IFCProductWrapper.
/// </param>
/// <param name="setter">
/// The IFCPlacementSetter.
/// </param>
/// <returns>
/// True if created successfully, false otherwise.
/// </returns>
static void CreateIFCSpace(ExporterIFC exporterIFC, SpatialElement spatialElement, IFCProductWrapper productWrapper, IFCPlacementSetter setter)
{
Autodesk.Revit.DB.Document document = spatialElement.Document;
ElementId levelId = spatialElement.Level != null ? spatialElement.Level.Id : ElementId.InvalidElementId;
double scale = exporterIFC.LinearScale;
ElementId catId = spatialElement.Category != null ? spatialElement.Category.Id : ElementId.InvalidElementId;
double dArea = 0.0;
Parameter param = spatialElement.get_Parameter(BuiltInParameter.ROOM_AREA);
if (param != null)
{
dArea = param.AsDouble();
dArea *= (scale * scale);
}
SpatialElementBoundaryOptions options = ExporterIFCUtils.GetSpatialElementBoundaryOptions(exporterIFC, spatialElement);
IList<CurveLoop> curveLoops = ExporterIFCUtils.GetRoomBoundaryAsCurveLoopArray(spatialElement, options, true);
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(levelId);
string strSpaceNumber = null;
string strSpaceName = null;
string strSpaceDesc = null;
bool isArea = spatialElement is Area;
if (!isArea)
{
Parameter paramRoomNum = spatialElement.get_Parameter(BuiltInParameter.ROOM_NUMBER);
if (paramRoomNum != null)
{
strSpaceNumber = paramRoomNum.AsString();
}
Parameter paramRoomName = spatialElement.get_Parameter(BuiltInParameter.ROOM_NAME);
if (paramRoomName != null)
{
strSpaceName = paramRoomName.AsString();
}
Parameter paramRoomComm = spatialElement.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS);
if (paramRoomComm != null)
{
strSpaceDesc = paramRoomComm.AsString();
}
}
else
{
Element level = document.get_Element(levelId);
if (level != null)
{
strSpaceNumber = level.Name + " GSA Design Gross Area";
}
}
//assign empty string if it is null
if (strSpaceNumber == null) strSpaceNumber = "";
if (strSpaceName == null) strSpaceName = "";
if (strSpaceDesc == null) strSpaceDesc = "";
IFCLabel name = IFCLabel.Create(strSpaceNumber);
IFCLabel longName = IFCLabel.Create(strSpaceName);
IFCLabel desc = IFCLabel.Create(strSpaceDesc);
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle localPlacement = setter.GetPlacement();
ElementType elemType = document.get_Element(spatialElement.GetTypeId()) as ElementType;
bool isObjectExternal = CategoryUtil.IsElementExternal(spatialElement);
IFCMeasureValue elevationWithFlooring = IFCMeasureValue.Create();
double roomHeight = 0.0;
roomHeight = GetHeight(spatialElement, scale, levelInfo);
double bottomOffset = 0.0;
Parameter paramBottomOffset = spatialElement.get_Parameter(BuiltInParameter.ROOM_LOWER_OFFSET);
bottomOffset = paramBottomOffset != null ? paramBottomOffset.AsDouble() : 0.0;
XYZ zDir = new XYZ(0, 0, 1);
XYZ orig = new XYZ(0, 0, levelInfo.Elevation + bottomOffset);
//.........这里部分代码省略.........
示例8: ExportSpatialElement
/// <summary>
/// Export spatial elements, including rooms, areas and spaces. 1st level space boundaries.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="spatialElement">
/// The spatial element.
/// </param>
/// <param name="productWrapper">
/// The IFCProductWrapper.
/// </param>
public static void ExportSpatialElement(ExporterIFC exporterIFC, SpatialElement spatialElement, IFCProductWrapper productWrapper)
{
//quick reject
bool isArea = spatialElement is Area;
if (isArea)
{
if (!IsAreaGrossInterior(exporterIFC, spatialElement))
return;
}
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
ElementId levelId = spatialElement.Level != null ? spatialElement.Level.Id : ElementId.InvalidElementId;
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, spatialElement, null, null, levelId))
{
CreateIFCSpace(exporterIFC, spatialElement, productWrapper, setter);
// Do not create boundary information, or extra property sets.
if (spatialElement is Area)
{
tr.Commit();
return;
}
if (exporterIFC.SpaceBoundaryLevel == 1)
{
Document document = spatialElement.Document;
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(levelId);
double baseHeightNonScaled = levelInfo.Elevation;
SpatialElementGeometryResults spatialElemGeomResult = s_SpatialElemGeometryCalculator.CalculateSpatialElementGeometry(spatialElement);
Solid spatialElemGeomSolid = spatialElemGeomResult.GetGeometry();
FaceArray faces = spatialElemGeomSolid.Faces;
foreach (Face face in faces)
{
IList<SpatialElementBoundarySubface> spatialElemBoundarySubfaces = spatialElemGeomResult.GetBoundaryFaceInfo(face);
foreach (SpatialElementBoundarySubface spatialElemBSubface in spatialElemBoundarySubfaces)
{
if (spatialElemBSubface.SubfaceType == SubfaceType.Side)
continue;
if (spatialElemBSubface.GetSubface() == null)
continue;
ElementId elemId = spatialElemBSubface.SpatialBoundaryElement.LinkInstanceId;
if (elemId == ElementId.InvalidElementId)
{
elemId = spatialElemBSubface.SpatialBoundaryElement.HostElementId;
}
Element boundingElement = document.get_Element(elemId);
if (boundingElement == null)
continue;
bool isObjectExt = CategoryUtil.IsElementExternal(boundingElement);
IFCGeometryInfo info = IFCGeometryInfo.CreateSurfaceGeometryInfo(spatialElement.Document.Application.VertexTolerance);
Face subFace = spatialElemBSubface.GetSubface();
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, subFace, XYZ.Zero, false);
IFCAnyHandle ifcOptionalHnd = IFCAnyHandle.Create();
foreach (IFCAnyHandle surfaceHnd in info.GetSurfaces())
{
IFCAnyHandle connectionGeometry = file.CreateConnectionSurfaceGeometry(surfaceHnd, ifcOptionalHnd);
IFCSpaceBoundary spaceBoundary = IFCSpaceBoundary.Create(spatialElement.Id, boundingElement.Id, connectionGeometry, IFCSpaceBoundaryType.Physical, isObjectExt);
if (!ProcessIFCSpaceBoundary(exporterIFC, spaceBoundary, file))
exporterIFC.RegisterIFCSpaceBoundary(spaceBoundary);
}
}
}
IList<IList<BoundarySegment>> roomBoundaries = spatialElement.GetBoundarySegments(ExporterIFCUtils.GetSpatialElementBoundaryOptions(exporterIFC, spatialElement));
double roomHeight = GetHeight(spatialElement, exporterIFC.LinearScale, levelInfo);
XYZ zDir = new XYZ(0, 0, 1);
foreach (IList<BoundarySegment> roomBoundaryList in roomBoundaries)
{
foreach (BoundarySegment roomBoundary in roomBoundaryList)
{
Element boundingElement = roomBoundary.Element;
if (boundingElement == null)
continue;
//.........这里部分代码省略.........
示例9: ExportFamilyInstanceAsMappedItem
//.........这里部分代码省略.........
{
IFCAnyHandle bodyRepresentation = IFCAnyHandle.Create();
IFCAnyHandle planRepresentation = IFCAnyHandle.Create();
// If we are using the instance geometry, ignore the transformation.
if (useInstanceGeometry)
trf = Transform.Identity;
// TODO: this code to be removed by ExtrusionAnalyzer code.
if (trySpecialColumnCreation)
{
XYZ rangeOffset = trf.Origin;
IFCFamilyInstanceExtrusionExportResults results;
if (range != null)
{
results = ExporterIFCUtils.ExportFamilyInstanceAsExtrusion(exporterIFC, familyInstance, useInstanceGeometry, range, overrideLevelId, extraParams);
}
else
{
results = ExporterIFCUtils.ExportFamilyInstanceAsExtrusion(exporterIFC, familyInstance, useInstanceGeometry, overrideLevelId, extraParams);
}
bodyRepresentation = results.GetExtrusionHandle();
extraOffset = results.ExtraOffset;
cutPairOpeningsForColumns = results.GetCutPairOpenings();
if (bodyRepresentation.HasValue)
{
typeInfo.MaterialId = results.MaterialId;
// add in level for real columns, not in-place ones.
Element actualLevel =
(overrideLevelId == ElementId.InvalidElementId) ? familyInstance.Level : doc.get_Element(overrideLevelId);
if (actualLevel != null)
{
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(actualLevel.Id);
double nonStoryLevelOffset = LevelUtil.GetNonStoryLevelOffsetIfAny(exporterIFC, actualLevel as Level);
if (range != null)
{
rangeOffset = new XYZ(rangeOffset.X, rangeOffset.Y, levelInfo.Elevation + nonStoryLevelOffset);
}
}
}
rangeOffset += extraOffset;
trf.Origin = rangeOffset;
}
Transform doorWindowTrf = Transform.Identity;
IFCAnyHandle dummyPlacement = IFCAnyHandle.Create();
if (doorWindowInfo != null)
{
doorWindowTrf = ExporterIFCUtils.GetTransformForDoorOrWindow(familyInstance, familySymbol, doorWindowInfo);
}
else
{
dummyPlacement = file.CreateLocalPlacement(IFCAnyHandle.Create(), file.CreateAxis2Placement3D());
extraParams.SetLocalPlacement(dummyPlacement);
}
bool needToCreate2d = (!exporterIFC.ExportAs2x2);
bool needToCreate3d = (!bodyRepresentation.HasValue);
if (needToCreate2d || needToCreate3d)
{
using (IFCTransformSetter trfSetter = IFCTransformSetter.Create())
{
if (doorWindowInfo != null)
示例10: CreateIFCSpace
/// <summary>
/// Creates IFC room/space/area item, not include boundaries.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="spatialElement">
/// The spatial element.
/// </param>
/// <param name="productWrapper">
/// The IFCProductWrapper.
/// </param>
/// <param name="setter">
/// The IFCPlacementSetter.
/// </param>
/// <returns>
/// True if created successfully, false otherwise.
/// </returns>
static bool CreateIFCSpace(ExporterIFC exporterIFC, SpatialElement spatialElement, IFCProductWrapper productWrapper, IFCPlacementSetter setter)
{
IList<CurveLoop> curveLoops = null;
try
{
SpatialElementBoundaryOptions options = ExporterIFCUtils.GetSpatialElementBoundaryOptions(exporterIFC, spatialElement);
curveLoops = ExporterIFCUtils.GetRoomBoundaryAsCurveLoopArray(spatialElement, options, true);
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
//Some spatial elements are not placed that have no boundary loops. Don't export them.
return false;
}
Autodesk.Revit.DB.Document document = spatialElement.Document;
ElementId levelId = spatialElement.Level != null ? spatialElement.Level.Id : ElementId.InvalidElementId;
double scale = exporterIFC.LinearScale;
ElementId catId = spatialElement.Category != null ? spatialElement.Category.Id : ElementId.InvalidElementId;
double dArea = 0.0;
Parameter param = spatialElement.get_Parameter(BuiltInParameter.ROOM_AREA);
if (param != null)
{
dArea = param.AsDouble();
dArea *= (scale * scale);
}
IFCLevelInfo levelInfo = exporterIFC.GetLevelInfo(levelId);
string strSpaceNumber = null;
string strSpaceName = null;
string strSpaceDesc = null;
bool isArea = spatialElement is Area;
if (!isArea)
{
Parameter paramRoomNum = spatialElement.get_Parameter(BuiltInParameter.ROOM_NUMBER);
if (paramRoomNum != null)
{
strSpaceNumber = paramRoomNum.AsString();
}
Parameter paramRoomName = spatialElement.get_Parameter(BuiltInParameter.ROOM_NAME);
if (paramRoomName != null)
{
strSpaceName = paramRoomName.AsString();
}
Parameter paramRoomComm = spatialElement.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS);
if (paramRoomComm != null)
{
strSpaceDesc = paramRoomComm.AsString();
}
}
else
{
Element level = document.GetElement(levelId);
if (level != null)
{
strSpaceNumber = level.Name + " GSA Design Gross Area";
}
}
string name = strSpaceNumber;
string longName = strSpaceName;
string desc = strSpaceDesc;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle localPlacement = setter.GetPlacement();
ElementType elemType = document.GetElement(spatialElement.GetTypeId()) as ElementType;
IFCInternalOrExternal internalOrExternal = CategoryUtil.IsElementExternal(spatialElement) ? IFCInternalOrExternal.External : IFCInternalOrExternal.Internal;
double roomHeight = 0.0;
roomHeight = GetHeight(spatialElement, scale, levelId, levelInfo);
double bottomOffset = 0.0;
Parameter paramBottomOffset = spatialElement.get_Parameter(BuiltInParameter.ROOM_LOWER_OFFSET);
bottomOffset = paramBottomOffset != null ? paramBottomOffset.AsDouble() : 0.0;
//.........这里部分代码省略.........