/// <summary> /// Internal constructor for ReferencePoint Elements that a persistent relationship to a Face /// </summary> /// <param name="faceReference"></param> /// <param name="uv"></param> private ReferencePoint(Reference faceReference, UV uv) { //Phase 1 - Check to see if the object exists and should be rebound var oldRefPt = ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.ReferencePoint>(Document); //There was a point, rebind to that, and adjust its position if (oldRefPt != null) { InternalSetReferencePoint(oldRefPt); InternalSetPointOnFace(faceReference, uv); return; } //Phase 2- There was no existing point, create one TransactionManager.Instance.EnsureInTransaction(Document); var edgePoint = Document.Application.Create.NewPointOnFace(faceReference, uv); InternalSetReferencePoint(Document.FamilyCreate.NewReferencePoint(edgePoint)); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(InternalElement); // otherwise the point value is invalid for downstream requests DocumentManager.Regenerate(); }
/// <summary> /// Internal constructor for ReferencePoint Elements that a persistent relationship to a Curve /// </summary> /// <param name="curveReference"></param> /// <param name="parameter"></param> /// <param name="measurementType"></param> /// <param name="measureFrom"></param> private ReferencePoint(Reference curveReference, double parameter, PointOnCurveMeasurementType measurementType, PointOnCurveMeasureFrom measureFrom) { //Phase 1 - Check to see if the object exists and should be rebound var oldRefPt = ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.ReferencePoint>(Document); //There was a point, rebind to that, and adjust its position if (oldRefPt != null) { InternalSetReferencePoint(oldRefPt); InternalSetPointOnCurve(curveReference, parameter, measurementType, measureFrom); return; } //Phase 2- There was no existing point, create one TransactionManager.Instance.EnsureInTransaction(Document); var plc = new PointLocationOnCurve(measurementType, parameter, measureFrom); var edgePoint = Document.Application.Create.NewPointOnEdge(curveReference, plc); InternalSetReferencePoint(Document.FamilyCreate.NewReferencePoint(edgePoint)); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(this.InternalElement); }
/// <summary> /// Create a Point Analysis Display in the current view /// </summary> /// <param name="view"></param> /// <param name="faceReference"></param> /// <param name="sampleLocations"></param> /// <param name="samples"></param> private FaceAnalysisDisplay(Autodesk.Revit.DB.View view, Reference faceReference, IEnumerable<Autodesk.Revit.DB.UV> sampleLocations, IEnumerable<double> samples) { var sfm = GetSpatialFieldManagerFromView(view); var sfmAndId = GetElementAndPrimitiveIdFromTrace(); // we can rebind as we're dealing with the same view if (sfmAndId != null && sfmAndId.Item1.Id == sfm.Id) { InternalSetSpatialFieldManager(sfmAndId.Item1); InternalSetPrimitiveId(sfmAndId.Item2); InternalSetSpatialFieldValues(sampleLocations, samples); return; } // the input view has changed, remove the old primitive from the old view if (sfmAndId != null) { var oldSfm = sfmAndId.Item1; var oldId = sfmAndId.Item2; oldSfm.RemoveSpatialFieldPrimitive(oldId); } // create a new spatial field primitive TransactionManager.Instance.EnsureInTransaction(Document); InternalSetSpatialFieldManager(sfm); var primitiveId = SpatialFieldManager.AddSpatialFieldPrimitive(faceReference); InternalSetPrimitiveId(primitiveId); InternalSetSpatialFieldValues(sampleLocations, samples); SetElementAndPrimitiveIdForTrace(SpatialFieldManager, primitiveId); TransactionManager.Instance.TransactionTaskDone(); }
/// <summary> /// Internal constructor for the AdaptiveComponent wrapper /// </summary> /// <param name="parms">Params on curve to reference</param> /// <param name="c">Curve to use as reference</param> /// <param name="fs">FamilySymbol to place</param> private AdaptiveComponent(double[] parms, Reference c, 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); InternalSetParamsAndCurve(parms, c); 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); InternalSetParamsAndCurve(parms, c); TransactionManager.Instance.TransactionTaskDone(); }
/// <summary> /// // Place the 36" x 48" window at the reference. /// </summary> /// <param name="eRef">The point reference picked from wall face.</param> protected void PlaceWindowAtReference(Reference eRef) { // Find the window type 36" x 48". FamilySymbol windowType = FindFamilySymbol("36\" x 48\""); if (windowType != null) { // Create the window. m_document.Document.Create.NewFamilyInstance(eRef.GlobalPoint, windowType, m_document.Document.GetElement(eRef), StructuralType.NonStructural); } }
private void InternalSetPointOnFace(Reference faceReference, Autodesk.Revit.DB.UV uv) { TransactionManager.Instance.EnsureInTransaction(Document); var edgePoint = Document.Application.Create.NewPointOnFace(faceReference, uv); InternalReferencePoint.SetPointElementReference(edgePoint); TransactionManager.Instance.TransactionTaskDone(); }
private void InternalSetPointOnCurve(Reference curveReference, double parameter, PointOnCurveMeasurementType measurementType, PointOnCurveMeasureFrom measureFrom) { TransactionManager.Instance.EnsureInTransaction(Document); var plc = new PointLocationOnCurve(measurementType, parameter, measureFrom); var edgePoint = Document.Application.Create.NewPointOnEdge(curveReference, plc); InternalReferencePoint.SetPointElementReference(edgePoint); TransactionManager.Instance.TransactionTaskDone(); }
private static Autodesk.DesignScript.Geometry.Surface Tag(Autodesk.DesignScript.Geometry.Surface srf, Autodesk.Revit.DB.Reference reference) { return(reference != null?ElementFaceReference.AddTag(srf, reference) : srf); }
private static Autodesk.DesignScript.Geometry.Curve Tag(Autodesk.DesignScript.Geometry.Curve curve, Autodesk.Revit.DB.Reference reference) { return(reference != null?ElementCurveReference.AddTag(curve, reference) : curve); }
public Face(DB.Document doc, DB.Reference reference) : base(doc, reference) { }
public Vertex(DB.Document doc, DB.Reference reference, int index) : base(doc, reference) { VertexIndex = index; }
public static Autodesk.Revit.DB.Element GetRevitElement(this Autodesk.Revit.DB.Reference reference) { return(RevitData.Instance.Document.GetElement(reference)); }
private static object Tag(object obj, Autodesk.Revit.DB.Reference reference) { return(obj); }
private static Autodesk.DesignScript.Geometry.Geometry Tag(Autodesk.DesignScript.Geometry.Geometry geo, Autodesk.Revit.DB.Reference reference) { return(geo); }
/// <summary> /// Get the edges and faces from the solid and convert them /// </summary> /// <param name="solid"></param> /// <param name="reference"></param> /// <param name="transform"></param> /// <returns></returns> public static IEnumerable <object> ConvertToMany(this Autodesk.Revit.DB.Solid solid, Autodesk.Revit.DB.Reference reference = null, Autodesk.DesignScript.Geometry.CoordinateSystem transform = null) { if (solid == null) { return(null); } try { var convertedGeoms = InternalConvertToMany(solid); return(convertedGeoms.Select(x => { return Tag(Transform(x, transform), reference); })); } catch (Exception) { return(null); } }
/// <summary> /// Internal constructor for the AdaptiveComponent wrapper /// </summary> /// <param name="parms">Params on curve to reference</param> /// <param name="c">Curve to use as reference</param> /// <param name="ft">familyType to place</param> private AdaptiveComponent(double[] parms, Reference c, FamilyType ft) { SafeInit(() => InitAdaptiveComponent(parms, c, ft)); }