/// <summary> /// Private constructor for creating a divided surface /// </summary> /// <param name="face"></param> /// <param name="uDivs"></param> /// <param name="vDivs"></param> /// <param name="rotation"></param> private DividedSurface(FaceReference face, int uDivs, int vDivs, double rotation) { // if the family instance is present in trace... var oldEle = ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.DividedSurface>(Document); // just mutate it... if (oldEle != null) { InternalSetDividedSurface(oldEle); InternalSetDivisions(uDivs, vDivs); InternalSetRotation(rotation); return; } // otherwise create a new family instance... TransactionManager.Instance.EnsureInTransaction(Document); var divSurf = Document.FamilyCreate.NewDividedSurface(face.InternalReference); InternalSetDividedSurface(divSurf); InternalSetDivisions(uDivs, vDivs); InternalSetRotation(rotation); TransactionManager.Instance.TransactionTaskDone(); // remember this new value ElementBinder.SetElementForTrace(this.InternalElement); }
/// <summary> /// Show a colored Face Analysis Display in the Revit View /// </summary> /// <param name="view"></param> /// <param name="faceReference"></param> /// <param name="sampleUvPoints"></param> /// <param name="samples"></param> /// <returns></returns> public static FaceAnalysisDisplay ByViewFacePointsAndValues(View view, FaceReference faceReference, double[][] sampleUvPoints, double[] samples) { if (view == null) { throw new ArgumentNullException("view"); } if (faceReference == null) { throw new ArgumentNullException("faceReference"); } if (sampleUvPoints == null) { throw new ArgumentNullException("sampleUvPoints"); } if (samples == null) { throw new ArgumentNullException("samples"); } if (sampleUvPoints.Length != samples.Length) { throw new Exception("The number of sample points and number of samples must be the same"); } return new FaceAnalysisDisplay(view.InternalView, faceReference.InternalReference, sampleUvPoints.ToUvs(), samples); }
/// <summary> /// Create a Reference Point by UV coordinates on a Face. This introduces a persistent relationship between /// Elements in the Revit document. /// </summary> /// <param name="face"></param> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public static ReferencePoint ByParametersOnFaceReference(FaceReference face, double u, double v) { if (!Document.IsFamilyDocument) { throw new Exception("ReferencePoint Elements can only be created in a Family Document"); } if (face == null) { throw new ArgumentNullException("face"); } return new ReferencePoint(face.InternalReference, new Autodesk.Revit.DB.UV(u, v)); }
/// <summary> /// Create a Revit DividedSurface on a face given the face and number of divisions in u and v directon /// and the rotation of the grid lines with respect to the natural UV parameterization of the face /// </summary> /// <param name="face"></param> /// <param name="uDivs"></param> /// <param name="vDivs"></param> /// <param name="gridRotation"></param> /// <returns></returns> public static DividedSurface ByFaceUVDivisionsAndRotation(FaceReference face, int uDivs, int vDivs, double gridRotation) { if (face == null) { throw new ArgumentNullException("face"); } if (uDivs <= 0) { throw new Exception("uDivs must be a positive integer"); } if (vDivs <= 0) { throw new Exception("vDivs must be a positive integer"); } return new DividedSurface(face, uDivs, vDivs, gridRotation); }
/// <summary> /// Create a Revit DividedSurface on a face given the face and number of divisions in u and v directon /// </summary> /// <param name="face"></param> /// <param name="uDivs"></param> /// <param name="vDivs"></param> /// <returns></returns> public static DividedSurface ByFaceAndUVDivisions(FaceReference face, int uDivs, int vDivs) { return ByFaceUVDivisionsAndRotation(face, uDivs, vDivs, 0.0); }