Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In summary,
This exception is throwned when creating an elevations views (doesnt have too much details unfortunately):
the code I'm using:
//a). Determine view family type to use
ViewFamilyType vft
= new FilteredElementCollector( doc )
.OfClass( typeof( ViewFamilyType ) )
.Cast<ViewFamilyType>()
.FirstOrDefault<ViewFamilyType>( x =>
ViewFamily.Section == x.ViewFamily && x.Name == "Building Section"); //is it enough to not include building section and always return this one??
//b). Determine section box (The Min and Max properties of the bounding box determine the crop region and far clip distance)
LocationCurve locCv = wall.Location as LocationCurve;
if (locCv != null && wallFace is PlanarFace) {
PlanarFace planarWallFc = wallFace as PlanarFace;
Line line = locCv.Curve as Line;
if (line != null && planarWallFc != null) {
List<double> zVal = new List<double>();
foreach (Face face in roomSolidFinish.Faces) //try using up to the center for determining the coordinates
{
PlanarFace plFc = face as PlanarFace;
if (plFc != null) {
if (plFc.FaceNormal.Z <= -0.98 || plFc.FaceNormal.Z >= 0.98) //here is an issue, some of the bottom faces do not have a flat -1 negative value!!
{
foreach (EdgeArray edgeArray in face.EdgeLoops) {
foreach (Edge edge in edgeArray) {
Curve cv = edge.AsCurve();
zVal.Add(cv.GetEndPoint(0).Z);
zVal.Add(cv.GetEndPoint(1).Z);
}
}
}
}
}
XYZ min = new XYZ(line.Length,zVal.Min(),- wall.WallType.Width);
XYZ max = new XYZ(-line.Length,zVal.Max() + wall.WallType.Width,0);
Transform t = Transform.Identity;
t.Origin = line.Evaluate(0.5,true);
t.BasisX = line.Direction;
t.BasisY = XYZ.BasisZ;
t.BasisZ = -line.Direction.CrossProduct(XYZ.BasisZ);
BoundingBoxXYZ sectionBox = new BoundingBoxXYZ();
sectionBox.Transform = t;
// sectionBox.Min = min;
// sectionBox.Max = max;
//
//
// ViewSection vwSec = ViewSection.CreateSection(doc,vft.Id,sectionBox);
the exception is throwed at line 47. If I comment line 47, there is no exception, and I can not create the view section.
Any possible root cause for this one?
Cheers,
Miguel G.
Solved! Go to Solution.