public XYZ GetViewSectionNormal(Document doc, ElevationMarker marker) { ViewSection elevViewSection = (ViewSection)doc.GetElement(marker.GetViewId(0)); double[][] transform = Matrix.transform2matrix(elevViewSection.CropBox.Transform); XYZ cbMinT = Matrix.matrix2xyz(Matrix.dot(transform, Matrix.xyz2matrix(elevViewSection.CropBox.Min))); XYZ cbMaxT = Matrix.matrix2xyz(Matrix.dot(transform, Matrix.xyz2matrix(elevViewSection.CropBox.Max))); XYZ elevViewSectionCoordEndPoint1 = new XYZ( cbMinT.X, cbMinT.Y, cbMaxT.Z); XYZ elevViewSectionCoordEndPoint2 = new XYZ( cbMinT.X, cbMinT.Y, cbMinT.Z); double[][] inverse = Matrix.invert(transform); XYZ cbEP1 = Matrix.matrix2xyz(Matrix.dot(inverse, Matrix.xyz2matrix(elevViewSectionCoordEndPoint1))); XYZ cbEP2 = Matrix.matrix2xyz(Matrix.dot(inverse, Matrix.xyz2matrix(elevViewSectionCoordEndPoint2))); // these points are already in the model coordiante system so no need to translate XYZ elevViewSectionNormal = cbEP2.Subtract(cbEP1); return(elevViewSectionNormal); }
public void SetCropBox(Document doc, ElevationMarker marker, Wall w) { ViewSection extElev = (ViewSection)doc.GetElement(marker.GetViewId(0)); BoundingBoxXYZ eecb = extElev.CropBox; XYZ cbboundsmin = extElev.CropBox.Min; XYZ cbboundsmax = extElev.CropBox.Max; LocationCurve wallCurve = w.Location as LocationCurve; XYZ wmin = wallCurve.Curve.GetEndPoint(0); XYZ wallEP2 = wallCurve.Curve.GetEndPoint(1); Parameter wallHeight = w.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM); XYZ wmax = new XYZ ( wallEP2.X, wallEP2.Y, wallEP2.Z + wallHeight.AsDouble() ); double[][] transform = Matrix.transform2matrix(eecb.Transform); double[][] transformInv = Matrix.invert(transform); double[] wMinMatrix = Matrix.xyz2matrix(wmin); double[] wMinTMatrix = Matrix.dot(transform, wMinMatrix); XYZ wMinT = Matrix.matrix2xyz(wMinTMatrix); double[] wMaxMatrix = Matrix.xyz2matrix(wmax); double[] wMaxTMatrix = Matrix.dot(transform, wMaxMatrix); XYZ wMaxT = Matrix.matrix2xyz(wMaxTMatrix); double[] originMatrix = Matrix.xyz2matrix(eecb.Transform.Origin); double[] originTMatrix = Matrix.dot(transform, originMatrix); XYZ originT = Matrix.matrix2xyz(originTMatrix); XYZ wMinTOrdered; XYZ wMaxTOrdered; Utility.ReorderMinMax(wMinT, wMaxT, out wMinTOrdered, out wMaxTOrdered); XYZ wbbboundsmin = new XYZ( wMinTOrdered.X - originT.X, wMinTOrdered.Y - originT.Y, cbboundsmin.Z ); XYZ wbbboundsmax = new XYZ( wMaxTOrdered.X - originT.X, wMaxTOrdered.Y - originT.Y - 0.01, cbboundsmax.Z ); eecb.set_Bounds(0, wbbboundsmin); eecb.set_Bounds(1, wbbboundsmax); extElev.CropBox = eecb; extElev.CropBoxVisible = false; }