public void VisualizeLines(ICollection <UVLine> lines, double elevation) { using (Transaction t = new Transaction(OSM_FOR_REVIT.RevitDocument, "Draw lines")) { t.Start(); FailureHandlingOptions failOpt = t.GetFailureHandlingOptions(); failOpt.SetFailuresPreprocessor(new CurveDrawingWarningSwallower()); t.SetFailureHandlingOptions(failOpt); Plane p = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ(0, 0, elevation)); SketchPlane skp = SketchPlane.Create(OSM_FOR_REVIT.RevitDocument, p); foreach (UVLine item in lines) { //unit conversion SpatialAnalysis.Geometry.UV start = item.Start.Copy(); unitConversion.Transform(start); SpatialAnalysis.Geometry.UV end = item.End.Copy(); unitConversion.Transform(end); //revit drawing part try { XYZ p1 = new XYZ(start.U, start.V, elevation); XYZ p2 = new XYZ(end.U, end.V, elevation); Line l = Line.CreateBound(p1, p2); OSM_FOR_REVIT.RevitDocument.Create.NewModelCurve(l, skp); } catch (Exception e) { MessageBox.Show(e.Report()); } } t.Commit(); } }
public void VisualizePoint(SpatialAnalysis.Geometry.UV pnt, double size, double elevation) { //unit conversion SpatialAnalysis.Geometry.UV p = pnt.Copy(); unitConversion.Transform(p); //revit drawing XYZ p1 = new XYZ(p.U - size / 2, p.V - size / 2, elevation); XYZ p2 = new XYZ(p.U + size / 2, p.V + size / 2, elevation); XYZ q1 = new XYZ(p.U + size / 2, p.V - size / 2, elevation); XYZ q2 = new XYZ(p.U - size / 2, p.V + size / 2, elevation); using (Transaction t = new Transaction(OSM_FOR_REVIT.RevitDocument, "Show Point")) { t.Start(); FailureHandlingOptions failOpt = t.GetFailureHandlingOptions(); failOpt.SetFailuresPreprocessor(new CurveDrawingWarningSwallower()); t.SetFailureHandlingOptions(failOpt); Plane pln = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ(0, 0, elevation)); SketchPlane skp = SketchPlane.Create(OSM_FOR_REVIT.RevitDocument, pln); Line l1 = Line.CreateBound(p1, p2); Line l2 = Line.CreateBound(q1, q2); OSM_FOR_REVIT.RevitDocument.Create.NewModelCurve(l1, skp); OSM_FOR_REVIT.RevitDocument.Create.NewModelCurve(l2, skp); t.Commit(); } p1 = null; p2 = null; q1 = null; q2 = null; }
public SpatialAnalysis.Geometry.UV PickPoint(string message) { UIDocument uidoc = new Autodesk.Revit.UI.UIDocument(OSM_FOR_REVIT.RevitDocument); XYZ xyz = uidoc.Selection.PickPoint(message); var revitUV = new SpatialAnalysis.Geometry.UV(xyz.X, xyz.Y); UnitConversion.Transform(revitUV, Length_Unit_Types.FEET, unitConversion.FromUnit); return(revitUV); }
public void VisualizePolygon(SpatialAnalysis.Geometry.UV[] points, double elevation) { //create a deep copy of the list var copy = new SpatialAnalysis.Geometry.UV[points.Length]; int pointCount = 0; foreach (var item in points) { copy[pointCount] = new SpatialAnalysis.Geometry.UV(item); pointCount++; } //transform units unitConversion.Transform(copy); //draw in revit using (Transaction t = new Transaction(OSM_FOR_REVIT.RevitDocument, "Draw Boundary")) { t.Start(); FailureHandlingOptions failOpt = t.GetFailureHandlingOptions(); failOpt.SetFailuresPreprocessor(new CurveDrawingWarningSwallower()); t.SetFailureHandlingOptions(failOpt); Plane p = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ(0, 0, elevation)); SketchPlane skp = SketchPlane.Create(OSM_FOR_REVIT.RevitDocument, p); for (int i = 0; i < copy.Length; i++) { try { XYZ p1 = new XYZ(copy[i].U, copy[i].V, elevation); int j = (i == copy.Length - 1) ? 0 : i + 1; XYZ p2 = new XYZ(copy[j].U, copy[j].V, elevation); Line l = Line.CreateBound(p1, p2); OSM_FOR_REVIT.RevitDocument.Create.NewModelCurve(l, skp); } catch (Exception e) { MessageBox.Show(e.Report()); } } t.Commit(); } }
/// <summary> /// Initializes a new instance of the <see cref="IsovistPolygon"/> class. /// </summary> /// <param name="points">The points that represent the isovist polygon.</param> /// <param name="vantagePoint">The vantage point of the polygonal isovist.</param> public IsovistPolygon(UV[] points, UV vantagePoint) : base(points) { this.VantagePoint = vantagePoint; }
/// <summary> /// Finds a point on this line with a given parameter. /// </summary> /// <param name="u">The u.</param> /// <returns>UV.</returns> public UV FindPoint(double u) { UV p = this.Start + (u / (this.End.DistanceTo(this.Start))) * (this.End - this.Start); return(p); }
/// <summary> /// Gets the length squared of this line. /// </summary> /// <returns>System.Double.</returns> public double GetLengthSquared() { return(UV.GetLengthSquared(this.Start, this.End)); }
/// <summary> /// Initializes a new instance of the <see cref="UVLine"/> class. /// </summary> /// <param name="start">The start point.</param> /// <param name="end">The end point.</param> public UVLine(UV start, UV end) { this.Start = start; this.End = end; }
/// <summary> /// Initializes a new instance of the <see cref="StateBase"/> class. /// </summary> /// <param name="location">The location.</param> /// <param name="direction">The direction.</param> /// <param name="velocity">The velocity.</param> public StateBase(UV location, UV direction, UV velocity) { this.Direction = direction; this.Location = location; this.Velocity = velocity; }
/// <summary> /// Initializes a new instance of the <see cref="StateBase"/> class. /// </summary> /// <param name="location">The location.</param> /// <param name="direction">The direction.</param> public StateBase(UV location, UV direction) { this.Direction = direction; this.Velocity = direction.Copy(); this.Location = location; }
/// <summary> /// Gets the squared distance between two states. /// </summary> /// <param name="state1">The state1.</param> /// <param name="state2">The state2.</param> /// <returns>System.Double.</returns> public static double DistanceSquared(StateBase state1, StateBase state2) { return(UV.GetLengthSquared(state1.Direction, state2.Direction) + UV.GetLengthSquared(state1.Location, state2.Location) + UV.GetLengthSquared(state1.Velocity, state2.Velocity)); }