/// <summary> /// Private constructor for creating a divided surface /// </summary> /// <param name="elementFace"></param> /// <param name="uDivs"></param> /// <param name="vDivs"></param> /// <param name="rotation"></param> private DividedSurface(ElementFaceReference elementFace, 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(elementFace.InternalReference); InternalSetDividedSurface(divSurf); InternalSetDivisions(uDivs, vDivs); InternalSetRotation(rotation); TransactionManager.Instance.TransactionTaskDone(); // remember this new value ElementBinder.SetElementForTrace(this.InternalElement); }
/// <summary> /// Internal constructor for the AdaptiveComponent wrapper /// </summary> /// <param name="pts">Points to use as reference</param> /// <param name="f">Face to use as reference</param> /// <param name="fs">FamilySymbol to place</param> private AdaptiveComponent(double[][] pts, ElementFaceReference f, FamilySymbol fs) { // if the family instance is present in trace... var oldFam = ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.FamilyInstance>(Document); // just mutate it... if (oldFam != null) { InternalSetFamilyInstance(oldFam); if (fs.InternalFamilySymbol.Id != oldFam.Symbol.Id) InternalSetFamilySymbol(fs); InternalSetUvsAndFace(pts.ToUvs(), f.InternalReference ); return; } // otherwise create a new family instance... TransactionManager.Instance.EnsureInTransaction(Document); var fam = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(Element.Document, fs.InternalFamilySymbol); if (fam == null) throw new Exception("An adaptive component could not be found or created."); InternalSetFamilyInstance(fam); InternalSetUvsAndFace(pts.ToUvs(), f.InternalReference ); TransactionManager.Instance.TransactionTaskDone(); }
/// <summary> ///get curtain grid from element with curtain grid or grids /// </summary> /// <param name="curtainHolderElement"></param> /// <param name="elementFaceReference"></param> static public CurtainGrid ByElementAndReference(Element curtainHolderElement, ElementFaceReference elementFaceReference) { return new CurtainGrid(curtainHolderElement.InternalElement, elementFaceReference.InternalReference); }
private static ElementFaceReference TryGetFaceReference(ElementFaceReference curveObject) { return(curveObject); }
private static ElementFaceReference TryGetFaceReference(ElementFaceReference curveObject) { return curveObject; }
public static AdaptiveComponent ByParametersOnFace(Autodesk.DesignScript.Geometry.UV[] uvs, ElementFaceReference surface, FamilySymbol familySymbol) { if (uvs == null) { throw new ArgumentNullException("uvs"); } if (surface == null) { throw new ArgumentNullException("surface"); } if (familySymbol == null) { throw new ArgumentNullException("familySymbol"); } return new AdaptiveComponent(uvs.Select(x => new[] { x.U, x.V }).ToArray(), ElementFaceReference.TryGetFaceReference(surface), familySymbol); }
public static AdaptiveComponent ByParametersOnFace(double[][] uvs, ElementFaceReference faceReference, FamilySymbol familySymbol) { if (uvs == null) { throw new ArgumentNullException("uvs"); } if (faceReference == null) { throw new ArgumentNullException("faceReference"); } if (familySymbol == null) { throw new ArgumentNullException("familySymbol"); } return new AdaptiveComponent(uvs, ElementFaceReference.TryGetFaceReference(faceReference), familySymbol); }
private static ElementFaceReference TryGetFaceReference(ElementFaceReference surfaceObject) { return(surfaceObject); }
/// <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="elementFace"></param> /// <param name="uDivs"></param> /// <param name="vDivs"></param> /// <param name="gridRotation"></param> /// <returns></returns> public static DividedSurface ByFaceUVDivisionsAndRotation(ElementFaceReference elementFace, int uDivs, int vDivs, double gridRotation) { if (elementFace == null) { throw new ArgumentNullException("elementFace"); } 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(elementFace, 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="elementFace"></param> /// <param name="uDivs"></param> /// <param name="vDivs"></param> /// <returns></returns> public static DividedSurface ByFaceAndUVDivisions(ElementFaceReference elementFace, int uDivs, int vDivs) { return ByFaceUVDivisionsAndRotation(elementFace, uDivs, vDivs, 0.0); }
/// <summary> /// Show a colored Face Analysis Display in the Revit View /// </summary> /// <param name="view"></param> /// <param name="elementFaceReference"></param> /// <param name="sampleUvPoints"></param> /// <param name="samples"></param> /// <returns></returns> public static FaceAnalysisDisplay ByViewFacePointsAndValues(View view, ElementFaceReference elementFaceReference, double[][] sampleUvPoints, double[] samples) { if (view == null) { throw new ArgumentNullException("view"); } if (elementFaceReference == null) { throw new ArgumentNullException("elementFaceReference"); } 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, elementFaceReference.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="elementFace"></param> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public static ReferencePoint ByParametersOnFaceReference(ElementFaceReference elementFace, double u, double v) { if (!Document.IsFamilyDocument) { throw new Exception("ReferencePoint Elements can only be created in a Family Document"); } if (elementFace == null) { throw new ArgumentNullException("elementFace"); } return new ReferencePoint(elementFace.InternalReference, new UV(u, v)); }