public void Dispose() { Dispose(true); if(origin != null) origin.Dispose(); BackgroundPreviewViewModel.ViewCameraChanged -= OnViewCameraChanged; }
/// <summary> /// Creates a vector between the midpoint of two curves /// </summary> /// <param name="crv1"></param> /// <param name="crv2"></param> /// <search></search> public static Autodesk.DesignScript.Geometry.Vector ByTwoCurves(this Autodesk.DesignScript.Geometry.Curve crv1, Autodesk.DesignScript.Geometry.Curve crv2) { Autodesk.DesignScript.Geometry.Point pt1 = crv1.PointAtParameter(0.5); Autodesk.DesignScript.Geometry.Point pt2 = crv2.PointAtParameter(0.5); Autodesk.DesignScript.Geometry.Vector vec = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(pt1, pt2); pt1.Dispose(); pt2.Dispose(); return(vec); }
public static List <global::Revit.Elements.Element> CenterOnRoomLocation(List <global::Revit.Elements.Element> roomTag) { Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; foreach (var tag in roomTag) { if (tag.InternalElement is Autodesk.Revit.DB.FamilyInstance) { continue; } Autodesk.Revit.DB.Architecture.RoomTag internalRoomTag = (Autodesk.Revit.DB.Architecture.RoomTag)tag.InternalElement; Autodesk.DesignScript.Geometry.Point roomLocation = (Autodesk.DesignScript.Geometry.Point) doc.GetElement(internalRoomTag.TaggedLocalRoomId).ToDSType(true).GetLocation(); TransactionManager.Instance.EnsureInTransaction(doc); tag.SetLocation(roomLocation); TransactionManager.Instance.TransactionTaskDone(); roomLocation.Dispose(); } return(roomTag); }
/// <summary> /// Extends a straight line at both ends /// </summary> /// <param name="line"></param> /// <param name="distance"></param> /// <search></search> public static Autodesk.DesignScript.Geometry.Line ExtendAtBothEnds(this Autodesk.DesignScript.Geometry.Curve line, double distance) { Autodesk.DesignScript.Geometry.Point stPt = line.StartPoint; Autodesk.DesignScript.Geometry.Point endPt = line.EndPoint; Autodesk.DesignScript.Geometry.Vector vec1 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(endPt, stPt); Autodesk.DesignScript.Geometry.Vector vec2 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(stPt, endPt); Autodesk.DesignScript.Geometry.Point newStPt = stPt.Translate(vec1, distance) as Autodesk.DesignScript.Geometry.Point; Autodesk.DesignScript.Geometry.Point newEndPt = endPt.Translate(vec2, distance) as Autodesk.DesignScript.Geometry.Point; Autodesk.DesignScript.Geometry.Line newLine = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(newStPt, newEndPt); //Dispose redundant geometry stPt.Dispose(); endPt.Dispose(); vec1.Dispose(); vec2.Dispose(); newStPt.Dispose(); newEndPt.Dispose(); return(newLine); }
/// <summary> /// Compares a single curve to a list of curves to find any curves that have the same normalised vector. /// </summary> /// <param name="curve"></param> /// <param name="curves"></param> /// <search></search> public static List <Autodesk.DesignScript.Geometry.Curve> FindMatchingVectorCurves(this Autodesk.DesignScript.Geometry.Curve curve, List <Autodesk.DesignScript.Geometry.Curve> curves) { Autodesk.DesignScript.Geometry.Point stPt1 = curve.StartPoint; Autodesk.DesignScript.Geometry.Point endPt1 = curve.EndPoint; Autodesk.DesignScript.Geometry.Vector vec1 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(stPt1, endPt1).Normalized(); string str1 = vec1.ToString(); List <string> curveList = new List <string>(); foreach (var c in curves) { Autodesk.DesignScript.Geometry.Point stPt2 = c.StartPoint; Autodesk.DesignScript.Geometry.Point endPt2 = c.EndPoint; Autodesk.DesignScript.Geometry.Vector vec2 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(stPt2, endPt2).Normalized(); string str2 = vec2.ToString(); curveList.Add(str2); //Dispose redundant geometry stPt2.Dispose(); endPt2.Dispose(); vec2.Dispose(); } List <Autodesk.DesignScript.Geometry.Curve> matchingCurves = new List <Autodesk.DesignScript.Geometry.Curve>(); for (int i = 0; i < curveList.Count; i++) { if (str1 == curveList[i]) { matchingCurves.Add(curves[i]); } } if (matchingCurves.Count == 0) { List <string> revCurveList = new List <string>(); foreach (var c in curves) { Autodesk.DesignScript.Geometry.Point stPt2 = c.StartPoint; Autodesk.DesignScript.Geometry.Point endPt2 = c.EndPoint; Autodesk.DesignScript.Geometry.Vector vec2 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(endPt2, stPt2).Normalized(); string str2 = vec2.ToString(); revCurveList.Add(str2); //Dispose redundant geometry stPt2.Dispose(); endPt2.Dispose(); vec2.Dispose(); } for (int i = 0; i < revCurveList.Count; i++) { if (str1 == revCurveList[i]) { matchingCurves.Add(curves[i]); } } } //Dispose redundant geometry stPt1.Dispose(); endPt1.Dispose(); vec1.Dispose(); return(matchingCurves); }