本文整理汇总了C#中Element.get_BoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C# Element.get_BoundingBox方法的具体用法?C# Element.get_BoundingBox怎么用?C# Element.get_BoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element.get_BoundingBox方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportWallBase
/// <summary>
/// Main implementation to export walls.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="element">
/// The element.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="origWrapper">
/// The IFCProductWrapper.
/// </param>
/// <param name="overrideLevelId">
/// The level id.
/// </param>
/// <param name="range">
/// The range to be exported for the element.
/// </param>
/// <returns>
/// The exported wall handle.
/// </returns>
public static IFCAnyHandle ExportWallBase(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
IFCProductWrapper origWrapper, ElementId overrideLevelId, IFCRange range)
{
using (IFCProductWrapper localWrapper = IFCProductWrapper.Create(origWrapper))
{
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
Wall wallElement = element as Wall;
FamilyInstance famInstWallElem = element as FamilyInstance;
if (wallElement == null && famInstWallElem == null)
return null;
if (wallElement != null && IsWallCompletelyClipped(wallElement, exporterIFC, range))
return null;
// get global values.
Document doc = element.Document;
double scale = exporterIFC.LinearScale;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle contextOfItemsAxis = exporterIFC.Get3DContextHandle("Axis");
IFCAnyHandle contextOfItemsBody = exporterIFC.Get3DContextHandle("Body");
IFCRange zSpan = new IFCRange();
double depth = 0.0;
bool validRange = (range != null && !MathUtil.IsAlmostZero(range.Start - range.End));
bool exportParts = PartExporter.CanExportParts(wallElement);
if (exportParts && !PartExporter.CanExportElementInPartExport(wallElement, validRange? overrideLevelId : wallElement.Level.Id, validRange))
return null;
// get bounding box height so that we can subtract out pieces properly.
// only for Wall, not FamilyInstance.
if (wallElement != null && geometryElement != null)
{
BoundingBoxXYZ boundingBox = element.get_BoundingBox(null);
if (boundingBox == null)
return null;
zSpan = new IFCRange(boundingBox.Min.Z, boundingBox.Max.Z);
// if we have a top clipping plane, modify depth accordingly.
double bottomHeight = validRange ? Math.Max(zSpan.Start, range.Start) : zSpan.Start;
double topHeight = validRange ? Math.Min(zSpan.End, range.End) : zSpan.End;
depth = topHeight - bottomHeight;
if (MathUtil.IsAlmostZero(depth))
return null;
depth *= scale;
}
IFCAnyHandle axisRep = null;
IFCAnyHandle bodyRep = null;
bool exportingAxis = false;
Curve curve = null;
bool exportedAsWallWithAxis = false;
bool exportedBodyDirectly = false;
bool exportingInplaceOpenings = false;
Curve centerCurve = GetWallAxis(wallElement);
XYZ localXDir = new XYZ(1, 0, 0);
XYZ localYDir = new XYZ(0, 1, 0);
XYZ localZDir = new XYZ(0, 0, 1);
XYZ localOrig = new XYZ(0, 0, 0);
double eps = MathUtil.Eps();
if (centerCurve != null)
{
Curve baseCurve = GetWallAxisAtBaseHeight(wallElement);
curve = GetWallTrimmedCurve(wallElement, baseCurve);
IFCRange curveBounds;
XYZ oldOrig;
//.........这里部分代码省略.........
示例2: IsElementHiddenInView
/// <summary>
/// Checks whether a given Revit element 'e' is
/// hidden in a specified view 'v'.
/// If v has a crop box defined, e is
/// considered hidden if its bounding box is
/// outside or less than 25% contained in the
/// crop box. If e is not eliminated as hidden
/// by that test, its IsHidden predicate is
/// checked, followed by the visibility of its
/// category and all its parent categories in
/// the given view.
/// Return true if the given element e is hidden
/// in the view v. This might be due to:
/// - e lies outside the view crop box
/// - e is specifically hidden in the view, by element
/// - the category of e or one of its parent
/// categories is hidden in v.
/// </summary>
bool IsElementHiddenInView(
Element e,
View v)
{
if( v.CropBoxActive )
{
BoundingBoxXYZ viewBox = v.CropBox;
BoundingBoxXYZ elBox = e.get_BoundingBox( v );
Transform transInv = v.CropBox.Transform.Inverse;
elBox.Max = transInv.OfPoint( elBox.Max );
elBox.Min = transInv.OfPoint( elBox.Min );
// The transform above might switch
// max and min values.
if( elBox.Min.X > elBox.Max.X )
{
XYZ tmpP = elBox.Min;
elBox.Min = new XYZ( elBox.Max.X, elBox.Min.Y, 0 );
elBox.Max = new XYZ( tmpP.X, elBox.Max.Y, 0 );
}
if( elBox.Min.Y > elBox.Max.Y )
{
XYZ tmpP = elBox.Min;
elBox.Min = new XYZ( elBox.Min.X, elBox.Max.Y, 0 );
elBox.Max = new XYZ( tmpP.X, elBox.Min.Y, 0 );
}
if( elBox.Min.X > viewBox.Max.X
|| elBox.Max.X < viewBox.Min.X
|| elBox.Min.Y > viewBox.Max.Y
|| elBox.Max.Y < viewBox.Min.Y )
{
return true;
}
else
{
BoundingBoxXYZ inside = new BoundingBoxXYZ();
double x, y;
x = elBox.Max.X;
if( elBox.Max.X > viewBox.Max.X )
x = viewBox.Max.X;
y = elBox.Max.Y;
if( elBox.Max.Y > viewBox.Max.Y )
y = viewBox.Max.Y;
inside.Max = new XYZ( x, y, 0 );
x = elBox.Min.X;
if( elBox.Min.X < viewBox.Min.X )
x = viewBox.Min.X;
y = elBox.Min.Y;
if( elBox.Min.Y < viewBox.Min.Y )
y = viewBox.Min.Y;
inside.Min = new XYZ( x, y, 0 );
double eBBArea = ( elBox.Max.X - elBox.Min.X )
* ( elBox.Max.Y - elBox.Min.Y );
double einsideArea =
( inside.Max.X - inside.Min.X )
* ( inside.Max.Y - inside.Min.Y );
double factor = einsideArea / eBBArea;
if( factor < 0.25 )
return true;
}
}
//.........这里部分代码省略.........
示例3: ExportWallBase
/// <summary>
/// Main implementation to export walls.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="connectedWalls">Information about walls joined to this wall.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="origWrapper">The ProductWrapper.</param>
/// <param name="overrideLevelId">The level id.</param>
/// <param name="range">The range to be exported for the element.</param>
/// <returns>The exported wall handle.</returns>
public static IFCAnyHandle ExportWallBase(ExporterIFC exporterIFC, Element element, IList<IList<IFCConnectedWallData>> connectedWalls,
GeometryElement geometryElement, ProductWrapper origWrapper, ElementId overrideLevelId, IFCRange range)
{
// Check cases where we choose not to export early.
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
Wall wallElement = element as Wall;
FamilyInstance famInstWallElem = element as FamilyInstance;
FaceWall faceWall = element as FaceWall;
bool exportingWallElement = (wallElement != null);
bool exportingFamilyInstance = (famInstWallElem != null);
bool exportingFaceWall = (faceWall != null);
if (!exportingWallElement && !exportingFamilyInstance && !exportingFaceWall)
return null;
if (exportingWallElement && IsWallCompletelyClipped(wallElement, exporterIFC, range))
return null;
IFCRange zSpan = null;
double depth = 0.0;
bool validRange = (range != null && !MathUtil.IsAlmostZero(range.Start - range.End));
bool exportParts = PartExporter.CanExportParts(element);
if (exportParts && !PartExporter.CanExportElementInPartExport(element, validRange ? overrideLevelId : element.LevelId, validRange))
return null;
IList<Solid> solids = new List<Solid>();
IList<Mesh> meshes = new List<Mesh>();
bool exportingInplaceOpenings = false;
if (!exportParts)
{
if (exportingWallElement || exportingFaceWall)
{
GetSolidsAndMeshes(geometryElement, range, ref solids, ref meshes);
if (solids.Count == 0 && meshes.Count == 0)
return null;
}
else
{
GeometryElement geomElemToUse = GetGeometryFromInplaceWall(famInstWallElem);
if (geomElemToUse != null)
{
exportingInplaceOpenings = true;
}
else
{
exportingInplaceOpenings = false;
geomElemToUse = geometryElement;
}
Transform trf = Transform.Identity;
if (geomElemToUse != geometryElement)
trf = famInstWallElem.GetTransform();
SolidMeshGeometryInfo solidMeshCapsule = GeometryUtil.GetSplitSolidMeshGeometry(geomElemToUse, trf);
solids = solidMeshCapsule.GetSolids();
meshes = solidMeshCapsule.GetMeshes();
}
}
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (ProductWrapper localWrapper = ProductWrapper.Create(origWrapper))
{
// get bounding box height so that we can subtract out pieces properly.
// only for Wall, not FamilyInstance.
if (exportingWallElement && geometryElement != null)
{
// There is a problem in the API where some walls with vertical structures are overreporting their height,
// making it appear as if there are clipping problems on export. We will work around this by getting the
// height directly from the solid(s).
if (solids.Count > 0 && meshes.Count == 0)
{
zSpan = GetBoundingBoxOfSolids(solids);
}
else
{
BoundingBoxXYZ boundingBox = wallElement.get_BoundingBox(null);
if (boundingBox != null)
zSpan = GetBoundingBoxZRange(boundingBox);
}
if (zSpan == null)
return null;
// if we have a top clipping plane, modify depth accordingly.
//.........这里部分代码省略.........
示例4: GetFrontView
ViewSection GetFrontView( Element e )
{
// Retrieve element bounding box
BoundingBoxXYZ bb = e.get_BoundingBox( null );
// Determine box size
XYZ size = bb.Max - bb.Min;
// Set up view from front with small gap
// between section and element
//XYZ pMax = new XYZ( -0.5 * size.X, 0.5 * size.Z, 0.5 * size.Y );
//XYZ pMin = new XYZ( 0.5 * size.X, -0.5 * size.Z, -0.5 * size.Y - 0.2 );
// Set up view from front in element midpoint
XYZ pMax = new XYZ( -0.5 * size.X, 0.5 * size.Z, 0.5 * size.Y );
XYZ pMin = new XYZ( 0.5 * size.X, -0.5 * size.Z, -0.5 * size.Y - 0.2 );
BoundingBoxXYZ bbView = new BoundingBoxXYZ();
bbView.Enabled = true;
bbView.Max = pMax;
bbView.Min = pMin;
// Set the transform
Transform tx = Transform.Identity;
// Determine element midpoint
XYZ pMid = 0.5 * ( bb.Max + bb.Min );
// Set it as origin
tx.Origin = pMid;
// Set view direction
tx.BasisX = -XYZ.BasisX;
tx.BasisY = XYZ.BasisZ;
tx.BasisZ = XYZ.BasisY;
bbView.Transform = tx;
// Create and return section view
Document doc = e.Document;
Transaction t = new Transaction( doc );
t.Start( "Create Section View" );
ViewSection viewSection = doc.Create.NewViewSection( bbView );
t.Commit();
return viewSection;
}
示例5: Stream
private void Stream( ArrayList data, Element elem )
{
data.Add( new Snoop.Data.ClassSeparator( typeof( Element ) ) );
try
{
data.Add( new Snoop.Data.String( "Name", elem.Name ) );
}
catch( Exception ex )
{
data.Add( new Snoop.Data.Exception( "Name", ex ) );
}
data.Add( new Snoop.Data.Int( "ID", elem.Id.IntegerValue ) );
data.Add( new Snoop.Data.String( "Unique ID", elem.UniqueId ) );
data.Add( new Snoop.Data.Object( "Category", elem.Category ) );
data.Add( new Snoop.Data.ElementId( "Object type", elem.GetTypeId(), elem.Document ) );
data.Add( new Snoop.Data.Object( "Level", elem.LevelId ) );
data.Add( new Snoop.Data.Object( "Document", elem.Document ) );
data.Add( new Snoop.Data.Object( "Location", elem.Location ) );
BoundingBoxXYZ bb = elem.get_BoundingBox( null );
if( null != bb )
{
data.Add( new Snoop.Data.Object( "Bounding box", bb ) );
}
try
{
data.Add( new Snoop.Data.Enumerable( "Materials", elem.GetMaterialIds( false ), elem.Document ) );
}
catch( Exception ex )
{
data.Add( new Snoop.Data.Exception( "Materials", ex ) );
}
data.Add( new Snoop.Data.ParameterSet( "Parameters", elem, elem.Parameters ) );
data.Add( new Snoop.Data.Enumerable( "Parameters map", elem.ParametersMap ) );
data.Add( new Snoop.Data.Object( "Design option", elem.DesignOption ) );
data.Add( new Snoop.Data.ElementId( "Group Id", elem.GroupId, elem.Document ) );
data.Add( new Snoop.Data.ElementId( "Created phase", elem.CreatedPhaseId, elem.Document ) );
data.Add( new Snoop.Data.ElementId( "Demolished phase", elem.DemolishedPhaseId, elem.Document ) );
try
{
data.Add( new Snoop.Data.ElementSet( "Similar object types", elem.GetValidTypes(), elem.Document ) );
}
catch( Exception ex )
{
data.Add( new Snoop.Data.Exception( "Similar object types", ex ) );
}
data.Add( new Snoop.Data.Bool( "Pinned", elem.Pinned ) );
data.Add( new Snoop.Data.ElementGeometry( "Geometry", elem, m_app.Application ) );
data.Add( new Snoop.Data.Object( "Analytical model", elem.GetAnalyticalModel() ) );
// Try to access the extensible storage of this element.
foreach( Schema schema in Schema.ListSchemas() )
{
String objectName = "Entity with Schema [" + schema.SchemaName + "]";
try
{
Entity entity = elem.GetEntity( schema );
if( !entity.IsValid() )
continue;
data.Add( new Snoop.Data.Object( objectName, entity ) );
}
catch( System.Exception ex )
{
data.Add( new Snoop.Data.Exception( objectName, ex ) );
}
}
// See if it is a type we are responsible for
Area area = elem as Area;
if( area != null )
{
Stream( data, area );
return;
}
AreaReinforcement areaReinforcement = elem as AreaReinforcement;
if( areaReinforcement != null )
{
Stream( data, areaReinforcement );
return;
}
AreaReinforcementCurve areaReinforcementCurve = elem as AreaReinforcementCurve;
if( areaReinforcementCurve != null )
{
Stream( data, areaReinforcementCurve );
return;
}
AreaTag areaTag = elem as AreaTag;
if( areaTag != null )
//.........这里部分代码省略.........
示例6: 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;
}
}
//.........这里部分代码省略.........
示例7: GetLocation
/// <summary>
/// Return a location point for a given element,
/// if one can be determined, regardless of whether
/// its Location property is a point or a curve.
/// </summary>
public static XYZ GetLocation( Element e )
{
XYZ p = null;
Location x = e.Location;
if( null == x )
{
BoundingBoxXYZ bb = e.get_BoundingBox( null );
if( null != bb )
{
p = Midpoint( bb.Min, bb.Max );
}
}
else
{
LocationPoint lp = x as LocationPoint;
if( null != lp )
{
p = lp.Point;
}
else
{
LocationCurve lc = x as LocationCurve;
if( null != lc )
{
Curve c = lc.Curve;
p = Midpoint( c.GetEndPoint( 0 ), c.GetEndPoint( 1 ) );
}
}
}
return p;
}
示例8: IsElementOutsideCropBox
/// <summary>
/// Return true if element is outside of view crop box
/// </summary>
bool IsElementOutsideCropBox( Element e, View v )
{
bool rc = v.CropBoxActive;
if( rc )
{
BoundingBoxXYZ vBox = v.CropBox;
BoundingBoxXYZ eBox = e.get_BoundingBox( v );
Transform tInv = v.CropBox.Transform.Inverse;
eBox.Max = tInv.OfPoint( eBox.Max );
eBox.Min = tInv.OfPoint( eBox.Min );
rc = ( eBox.Min.X > vBox.Max.X )
|| ( eBox.Max.X < vBox.Min.X )
|| ( eBox.Min.Y > vBox.Max.Y )
|| ( eBox.Max.Y < vBox.Min.Y );
}
return rc;
}
示例9: GetPlanViewBoundaryLoops
/// <summary>
/// Retrieve all plan view boundary loops from
/// all solids of given element united together.
/// If the element is a family instance, transform
/// its loops from the instance placement
/// coordinate system back to the symbol
/// definition one.
/// If no geometry can be determined, use the
/// bounding box instead.
/// </summary>
static JtLoops GetPlanViewBoundaryLoops(
Element e,
ref int nFailures)
{
Autodesk.Revit.Creation.Application creapp
= e.Document.Application.Create;
JtLoops loops = null;
Options opt = new Options();
GeometryElement geo = e.get_Geometry( opt );
if( null != geo )
{
Document doc = e.Document;
if( e is FamilyInstance )
{
// Retrieve family instance geometry
// transformed back to symbol definition
// coordinate space by inverting the
// family instance placement transformation
LocationPoint lp = e.Location
as LocationPoint;
Transform t = Transform.CreateTranslation(
-lp.Point );
Transform r = Transform.CreateRotationAtPoint(
XYZ.BasisZ, -lp.Rotation, lp.Point );
geo = geo.GetTransformed( t * r );
}
loops = GetPlanViewBoundaryLoopsGeo(
creapp, geo, ref nFailures );
}
if( null == loops || 0 == loops.Count )
{
Debug.Print(
"Unable to determine geometry for "
+ Util.ElementDescription( e )
+ "; using bounding box instead." );
BoundingBoxXYZ bb;
if( e is FamilyInstance )
{
bb = ( e as FamilyInstance ).Symbol
.get_BoundingBox( null );
}
else
{
bb = e.get_BoundingBox( null );
}
JtLoop loop = new JtLoop( 4 );
loop.Add( new Point2dInt( bb.Min ) );
loop.Add( new Point2dInt( bb.Max.X, bb.Min.Y ) );
loop.Add( new Point2dInt( bb.Max ) );
loop.Add( new Point2dInt( bb.Min.X, bb.Max.Y ) );
loops.Add( loop );
}
return loops;
}
示例10: ExportWallBase
/// <summary>
/// Main implementation to export walls.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="element">
/// The element.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="origWrapper">
/// The ProductWrapper.
/// </param>
/// <param name="overrideLevelId">
/// The level id.
/// </param>
/// <param name="range">
/// The range to be exported for the element.
/// </param>
/// <returns>
/// The exported wall handle.
/// </returns>
public static IFCAnyHandle ExportWallBase(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
ProductWrapper origWrapper, ElementId overrideLevelId, IFCRange range)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (ProductWrapper localWrapper = ProductWrapper.Create(origWrapper))
{
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
Wall wallElement = element as Wall;
FamilyInstance famInstWallElem = element as FamilyInstance;
FaceWall faceWall = element as FaceWall;
if (wallElement == null && famInstWallElem == null && faceWall == null)
return null;
if (wallElement != null && IsWallCompletelyClipped(wallElement, exporterIFC, range))
return null;
Document doc = element.Document;
double scale = exporterIFC.LinearScale;
double baseWallElevation = 0.0;
ElementId baseLevelId = ExporterUtil.GetBaseLevelIdForElement(element);
if (baseLevelId != ElementId.InvalidElementId)
{
Element baseLevel = doc.GetElement(baseLevelId);
if (baseLevel is Level)
baseWallElevation = (baseLevel as Level).Elevation;
}
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle contextOfItemsAxis = exporterIFC.Get3DContextHandle("Axis");
IFCAnyHandle contextOfItemsBody = exporterIFC.Get3DContextHandle("Body");
IFCRange zSpan = new IFCRange();
double depth = 0.0;
bool validRange = (range != null && !MathUtil.IsAlmostZero(range.Start - range.End));
bool exportParts = PartExporter.CanExportParts(element);
if (exportParts && !PartExporter.CanExportElementInPartExport(element, validRange ? overrideLevelId : element.Level.Id, validRange))
return null;
// get bounding box height so that we can subtract out pieces properly.
// only for Wall, not FamilyInstance.
if (wallElement != null && geometryElement != null)
{
BoundingBoxXYZ boundingBox = element.get_BoundingBox(null);
if (boundingBox == null)
return null;
zSpan = new IFCRange(boundingBox.Min.Z, boundingBox.Max.Z);
// if we have a top clipping plane, modify depth accordingly.
double bottomHeight = validRange ? Math.Max(zSpan.Start, range.Start) : zSpan.Start;
double topHeight = validRange ? Math.Min(zSpan.End, range.End) : zSpan.End;
depth = topHeight - bottomHeight;
if (MathUtil.IsAlmostZero(depth))
return null;
depth *= scale;
}
IFCAnyHandle axisRep = null;
IFCAnyHandle bodyRep = null;
bool exportingAxis = false;
Curve curve = null;
bool exportedAsWallWithAxis = false;
bool exportedBodyDirectly = false;
bool exportingInplaceOpenings = false;
Curve centerCurve = GetWallAxis(wallElement);
XYZ localXDir = new XYZ(1, 0, 0);
XYZ localYDir = new XYZ(0, 1, 0);
//.........这里部分代码省略.........
示例11: GetElementHeightFromBoundingBox
/// <summary>
/// Determine the height of any given element
/// from its bounding box.
/// </summary>
public Double GetElementHeightFromBoundingBox(
Element e)
{
// No need to retrieve the full element geometry.
// Even if there were, there would be no need to
// compute references, because they will not be
// used anyway!
//GeometryElement ge = e.get_Geometry(
// new Options() {
// ComputeReferences = true } );
//
//BoundingBoxXYZ boundingBox = ge.GetBoundingBox();
BoundingBoxXYZ bb = e.get_BoundingBox( null );
if( null == bb )
{
throw new ArgumentException(
"Expected Element 'e' to have a valid bounding box." );
}
return bb.Max.Z - bb.Min.Z;
}
示例12: ExportWallBase
/// <summary>
/// Main implementation to export walls.
/// </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 IFCProductWrapper.
/// </param>
/// <param name="overrideLevelId">
/// The level id.
/// </param>
/// <param name="range">
/// The range to be exported for the element.
/// </param>
/// <returns>
/// The exported wall handle.
/// </returns>
public static IFCAnyHandle ExportWallBase(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
IFCProductWrapper productWrapper, ElementId overrideLevelId, UV range)
{
using (IFCProductWrapper localWrapper = IFCProductWrapper.Create(productWrapper))
{
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
Wall wallElement = element as Wall;
FamilyInstance famInstWallElem = element as FamilyInstance;
if (wallElement == null && famInstWallElem == null)
return IFCAnyHandle.Create();
if (wallElement != null && IsWallCompletelyClipped(wallElement, exporterIFC, range))
return IFCAnyHandle.Create();
// get global values.
Document doc = element.Document;
double scale = exporterIFC.LinearScale;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle();
UV zSpan = UV.Zero;
double depth = 0.0;
bool validRange = (!MathUtil.IsAlmostZero(range.V - range.U));
// get bounding box height so that we can subtract out pieces properly.
// only for Wall, not FamilyInstance.
if (wallElement != null && geometryElement != null)
{
BoundingBoxXYZ boundingBox = element.get_BoundingBox(null);
zSpan = new UV(boundingBox.Min.Z, boundingBox.Max.Z);
// if we have a top clipping plane, modify depth accordingly.
double bottomHeight = validRange ? Math.Max(zSpan[0], range[0]) : zSpan[0];
double topHeight = validRange ? Math.Min(zSpan[1], range[1]) : zSpan[1];
depth = topHeight - bottomHeight;
if (MathUtil.IsAlmostZero(depth))
return IFCAnyHandle.Create();
depth *= scale;
}
IFCAnyHandle axisRep = IFCAnyHandle.Create();
IFCAnyHandle bodyRep = IFCAnyHandle.Create();
bool exportingAxis = false;
Curve curve = null;
bool exportedAsWallWithAxis = false;
bool exportedBodyDirectly = false;
bool exportingInplaceOpenings = false;
Curve centerCurve = GetWallAxis(wallElement);
XYZ localXDir = new XYZ(1, 0, 0);
XYZ localYDir = new XYZ(0, 1, 0);
XYZ localZDir = new XYZ(0, 0, 1);
XYZ localOrig = new XYZ(0, 0, 0);
double eps = MathUtil.Eps();
if (centerCurve != null)
{
Curve baseCurve = GetWallAxisAtBaseHeight(wallElement);
curve = GetWallTrimmedCurve(wallElement, baseCurve);
UV curveBounds;
XYZ oldOrig;
GeometryUtil.GetAxisAndRangeFromCurve(curve, out curveBounds, out localXDir, out oldOrig);
localOrig = oldOrig;
if (baseCurve != null)
{
if (!validRange || (MathUtil.IsAlmostEqual(range[0], zSpan[0])))
{
//.........这里部分代码省略.........
示例13: CreateSplitLevelRangesForElement
/// <summary>
/// Creates a list of ranges to split an element.
/// </summary>
/// <remarks>
/// We may need to split an element (e.g. column) into parts by level.
/// </remarks>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="exportType">
/// The export type.
/// </param>
/// <param name="element">
/// The element.
/// </param>
/// <param name="levels">
/// The levels to split the element.
/// </param>
/// <param name="ranges">
/// The ranges to split the element.
/// </param>
public static void CreateSplitLevelRangesForElement(ExporterIFC exporterIFC, IFCExportType exportType, Element elem,
out IList<ElementId> levels, out IList<UV> ranges)
{
// If we are exporting a column, we may need to split it into parts by level. Create a list of ranges.
levels = new List<ElementId>();
ranges = new List<UV>();
double extension = GetLevelExtension();
if ((exportType == IFCExportType.ExportColumnType) && (exporterIFC.WallAndColumnSplitting))
{
BoundingBoxXYZ boundingBox = elem.get_BoundingBox(null);
{
UV zSpan = new UV(boundingBox.Min.Z, boundingBox.Max.Z);
if (zSpan.U < zSpan.V)
{
IDictionary<ElementId, IFCLevelInfo> storeys = exporterIFC.GetLevelInfos();
foreach (KeyValuePair<ElementId, IFCLevelInfo> storey in storeys)
{
IFCLevelInfo levelInfo = storey.Value;
// endBelowLevel
if (zSpan.V < levelInfo.Elevation + extension)
continue;
// startAboveLevel
if ((!MathUtil.IsAlmostZero(levelInfo.DistanceToNextLevel)) &&
(zSpan.U > levelInfo.Elevation + levelInfo.DistanceToNextLevel - extension))
continue;
bool startBelowLevel = (zSpan.U < levelInfo.Elevation - extension);
bool endAboveLevel = ((!MathUtil.IsAlmostZero(levelInfo.DistanceToNextLevel)) &&
(zSpan.V > levelInfo.Elevation + levelInfo.DistanceToNextLevel + extension));
if (!startBelowLevel && !endAboveLevel)
break;
UV currentSpan = new UV(
startBelowLevel ? levelInfo.Elevation : zSpan.U,
endAboveLevel ? (levelInfo.Elevation + levelInfo.DistanceToNextLevel) : zSpan.V);
ranges.Add(currentSpan);
levels.Add(storey.Key);
}
}
}
}
}