private void GetUVArray(BoundingBoxUV bb, double interval, out List <double> uList, out List <double> vList) { uList = new List <double>(); vList = new List <double>(); double offset = 0.05; try { for (double u = bb.Min.U + offset; u < bb.Max.U; u += interval) { uList.Add(u); } if (uList[uList.Count - 1] < bb.Max.U - offset) { uList.Add(bb.Max.U - offset); } for (double v = bb.Min.V + offset; v < bb.Max.V; v += interval) { vList.Add(v); } if (vList[vList.Count - 1] < bb.Max.V - offset) { vList.Add(bb.Max.V - offset); } } catch (Exception ex) { MessageBox.Show("Failed to get UV array.\n" + ex.Message, "Get UV Array", MessageBoxButton.OK, MessageBoxImage.Warning); } }
Stream(ArrayList data, BoundingBoxUV bndBox) { data.Add(new Snoop.Data.ClassSeparator(typeof(BoundingBoxUV))); data.Add(new Snoop.Data.Uv("Min", bndBox.Min)); data.Add(new Snoop.Data.Uv("Max", bndBox.Max)); }
static void GetViewTransform(View v) { XYZ origin = v.Origin; BoundingBoxXYZ cropbox = v.CropBox; BoundingBoxUV outline = v.Outline; UV dOutline = outline.Max - outline.Min; XYZ dCropbox = cropbox.Max - cropbox.Min; double scaleX = dCropbox.X / dOutline.U; double scaleY = dCropbox.Y / dOutline.V; Debug.Print( "{0} {1} origin {2} scale {3} sx {4} sy {5} cropbox {6} d {7} outline {8} d {9}", v.Name, v.Id, Util.PointString(origin), Util.RealString(v.Scale), Util.RealString(scaleX), Util.RealString(scaleY), Util.BoundingBoxString(cropbox), Util.PointString(dCropbox), Util.BoundingBoxString(outline), Util.PointString(dOutline)); }
public override Value Evaluate(FSharpList <Value> args) { BoundingBoxUV bbox = null; object arg0 = ((Value.Container)args[0]).Item; Autodesk.Revit.DB.Face f; var faceRef = arg0 as Reference; if (faceRef != null) { f = dynRevitSettings.Doc.Document.GetElement(faceRef.ElementId).GetGeometryObjectFromReference(faceRef) as Autodesk.Revit.DB.Face; } else { f = arg0 as Autodesk.Revit.DB.Face; } if (f != null) { bbox = f.GetBoundingBox(); } var min = Vector.by_coordinates(bbox.Min.U, bbox.Min.V); var max = Vector.by_coordinates(bbox.Max.U, bbox.Max.V); return(Value.NewContainer(DSCoreNodes.Domain2D.ByMinimumAndMaximum(min, max))); }
public Result Execute( ExternalCommandData commandData, ref String message, ElementSet elements) { UIApplication app = commandData.Application; Document doc = app.ActiveUIDocument.Document; ViewSheet currentSheet = doc.ActiveView as ViewSheet; //foreach( View v in currentSheet.Views ) // 2014 warning 'Autodesk.Revit.DB.ViewSheet.Views' is obsolete. Use GetAllPlacedViews() instead. foreach (ElementId id in currentSheet.GetAllPlacedViews()) // 2015 { View v = doc.GetElement(id) as View; // the values returned here do not seem to // accurately reflect the positions of the // views on the sheet: BoundingBoxUV loc = v.Outline; Debug.Print( "Coordinates of {0} view '{1}': {2}", v.ViewType, v.Name, Util.PointString(loc.Min)); } return(Result.Failed); }
/// <summary> /// Compute the value of face on specific point /// </summary> /// <param name="face"></param> /// <param name="uvPts"></param> /// <param name="valList"></param> /// <param name="measurementNo"></param> private static void ComputeValueAtPointForFace(Face face, out IList <UV> uvPts, out IList <ValueAtPoint> valList, int measurementNo) { List <double> doubleList = new List <double>(); uvPts = new List <UV>(); valList = new List <ValueAtPoint>(); BoundingBoxUV bb = face.GetBoundingBox(); for (double u = bb.Min.U; u < bb.Max.U + 0.0000001; u = u + (bb.Max.U - bb.Min.U) / 1) { for (double v = bb.Min.V; v < bb.Max.V + 0.0000001; v = v + (bb.Max.V - bb.Min.V) / 1) { UV uvPnt = new UV(u, v); uvPts.Add(uvPnt); XYZ faceXYZ = face.Evaluate(uvPnt); // Specify three values for each point for (int ii = 1; ii <= measurementNo; ii++) { doubleList.Add(faceXYZ.DistanceTo(XYZ.Zero) * ii); } valList.Add(new ValueAtPoint(doubleList)); doubleList.Clear(); } } }
/// <summary> /// Prepares a container object that carries out the calculations without invoking Revit API calls. /// </summary> /// <param name="element">The element for the calculations.</param> /// <returns>The container.</returns> public static MultithreadedCalculationContainer CreateContainer(Element element) { Document doc = element.Document; View activeView = doc.GetElement(s_activeViewId) as View; // Figure out which is the largest face facing the user XYZ viewDirection = activeView.ViewDirection.Normalize(); Face biggestFace = GetBiggestFaceFacingUser(element, viewDirection); // Get or create SpatialFieldManager for AVF results SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(activeView); if (sfm == null) { sfm = SpatialFieldManager.CreateSpatialFieldManager(activeView, 1); } // Reference the target face s_spatialFieldId = sfm.AddSpatialFieldPrimitive(biggestFace.Reference); // Compute the range of U and V for the calculation BoundingBoxUV bbox = biggestFace.GetBoundingBox(); return(new MultithreadedCalculationContainer(doc.PathName, bbox.Min, bbox.Max)); }
void setupParticleSystem(Autodesk.Revit.DB.Face f, int uDiv, int vDiv, double springDampening, double springRestLength, double springConstant, double mass) { BoundingBoxUV bbox = f.GetBoundingBox(); double uStep = (bbox.Max.U - bbox.Min.U) / uDiv; double vStep = (bbox.Max.V - bbox.Min.V) / vDiv; for (int j = 0; j <= uDiv; j++) // Y axis is outer loop { double u = bbox.Min.U + uStep * j; for (int i = 0; i <= vDiv; i++) // X axis is inner loop { double v = bbox.Min.V + vStep * i; Particle a = particleSystem.makeParticle(mass, f.Evaluate(new UV(u, v)), false); if (i > 0) { particleSystem.makeSpring(particleSystem.getParticle((i - 1) + (j * (vDiv + 1))), a, springRestLength, springConstant, springDampening); } if (j > 0) { Particle b = particleSystem.getParticle(i + ((j - 1) * (vDiv + 1))); particleSystem.makeSpring(a, b, springRestLength, springConstant, springDampening); } if (i == 0 || i == vDiv || j == 0 || j == uDiv) { a.makeFixed(); } } } }
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandData cdata = commandData; Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application; Document doc = commandData.Application.ActiveUIDocument.Document; UIDocument uiDoc = commandData.Application.ActiveUIDocument; Transaction trans = new Transaction(doc, "Revit.SDK.Samples.AnalysisVisualizationFramework"); trans.Start(); SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(doc.ActiveView); if (sfm == null) { sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 1); } IList <Reference> refList = new List <Reference>(); refList = uiDoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Face); foreach (Reference reference in refList) { IList <UV> uvPts = new List <UV>(); List <double> doubleList = new List <double>(); IList <ValueAtPoint> valList = new List <ValueAtPoint>(); Face face = doc.GetElement(reference).GetGeometryObjectFromReference(reference) as Face; BoundingBoxUV bb = face.GetBoundingBox(); UV min = bb.Min; UV max = bb.Max; for (double u = min.U; u < max.U; u += (max.U - min.U) / 10) { for (double v = min.V; v < max.V; v += (max.V - min.V) / 10) { UV uv = new UV(u, v); if (face.IsInside(uv)) { uvPts.Add(uv); doubleList.Add(v + DateTime.Now.Second); valList.Add(new ValueAtPoint(doubleList)); doubleList.Clear(); } } } FieldDomainPointsByUV pnts = new FieldDomainPointsByUV(uvPts); FieldValues vals = new FieldValues(valList); int idx = sfm.AddSpatialFieldPrimitive(reference); AnalysisResultSchema resultSchema = new AnalysisResultSchema("Schema 1", "Schema 1 Description"); sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, sfm.RegisterResult(resultSchema)); } trans.Commit(); return(Result.Succeeded); }
private void SetViewForSheet(View view, ViewSheet sheet, int scale) { if (scale > 0) { try { view.Scale = scale; } catch (Exception ex) { } } try { if (Viewport.CanAddViewToSheet(view.Document, sheet.Id, view.Id)) { BoundingBoxUV sheetBox = sheet.Outline; double yPosition = (sheetBox.Max.V - sheetBox.Min.V) / 2 + sheetBox.Min.V; double xPosition = (sheetBox.Max.U - sheetBox.Min.U) / 2 + sheetBox.Min.U; XYZ orig = new XYZ(xPosition, yPosition, 0); Viewport viewport = Viewport.Create(view.Document, sheet.Id, view.Id, orig); } else { } } catch (ArgumentException ex) { } }
private void SetViewForSheet(View view, ViewSheet sheet, int scale) { if (scale > 0) { try { view.Scale = scale; } catch (Exception ex) { } } try { if (Viewport.CanAddViewToSheet(view.Document, sheet.Id, view.Id)) { BoundingBoxUV sheetBox = sheet.Outline; XYZ sheetOrigin = sheet.Origin; Viewport viewport = Viewport.Create(view.Document, sheet.Id, view.Id, XYZ.Zero); BoundingBoxXYZ viewportBoundingBox = viewport.get_BoundingBox(sheet); XYZ viewportOrigin = viewportBoundingBox.Min; ElementTransformUtils.MoveElement(view.Document, viewport.Id, new XYZ(sheetOrigin.X - viewportOrigin.X, sheetOrigin.Y - viewportOrigin.Y, 0)); } else { } } catch (ArgumentException ex) { } }
/// <summary> /// Calculate the appropriate distance between the views lay on the sheet. /// </summary> /// <param name="bBox">The outline of sheet.</param> /// <param name="amount">Amount of views.</param> /// <param name="x">Distance in x axis between each view</param> /// <param name="y">Distance in y axis between each view</param> private void CalculateDistance(BoundingBoxUV bBox, int amount, ref double x, ref double y) { double xLength = (bBox.Max.U - bBox.Min.U) * (1 - TITLEBAR); double yLength = (bBox.Max.V - bBox.Min.V); //calculate appropriate rows numbers. double result = Math.Sqrt(amount); while (0 < (result - (int)result)) { amount = amount + 1; result = Math.Sqrt(amount); } m_rows = result; double area = xLength * yLength / amount; //calculate appropriate distance between the views. if (bBox.Max.U > bBox.Max.V) { x = Math.Sqrt(area / GOLDENSECTION); y = GOLDENSECTION * x; } else { y = Math.Sqrt(area / GOLDENSECTION); x = GOLDENSECTION * y; } }
/// <summary> /// Return polygon loops representing the size /// and location of given sheet and all the /// viewports it contains, regardless of type. /// </summary> static JtLoops GetSheetViewportLoops( SheetModelCollections modelCollections, ViewSheet sheet) { Document doc = sheet.Document; List <Viewport> viewports = sheet .GetAllViewports() .Select <ElementId, Viewport>( id => doc.GetElement(id) as Viewport) .ToList <Viewport>(); int n = viewports.Count; modelCollections.ViewsInSheet[sheet.Id] = new List <ViewData>(n); JtLoops sheetViewportLoops = new JtLoops(n + 1); // sheet.get_BoundingBox( null ) returns (-100,-100),(100,100) BoundingBoxUV bb = sheet.Outline; // model coordinates (0,0), (2.76,1.95) JtBoundingBox2dInt ibb = new JtBoundingBox2dInt(); // millimeters (0,0),(840,...) ibb.ExpandToContain(new Point2dInt(bb.Min)); ibb.ExpandToContain(new Point2dInt(bb.Max)); JtLoop loop = new JtLoop(ibb.Corners); sheetViewportLoops.Add(loop); foreach (Viewport vp in viewports) { XYZ center = vp.GetBoxCenter(); // not used Outline outline = vp.GetBoxOutline(); ibb.Init(); ibb.ExpandToContain( new Point2dInt(outline.MinimumPoint)); ibb.ExpandToContain( new Point2dInt(outline.MaximumPoint)); loop = new JtLoop(ibb.Corners); sheetViewportLoops.Add(loop); ViewData d = new ViewData(); d.Id = vp.ViewId; d.ViewportBoundingBox = loop.BoundingBox; modelCollections.ViewsInSheet[sheet.Id].Add( d); } return(sheetViewportLoops); }
public void PaintSolid(Document doc, Solid s, double value) { int schemaId = -1; var rnd = new Random(); View view = doc.ActiveView; using (Transaction transaction = new Transaction(doc)) { if (transaction.Start("Create model curves") == TransactionStatus.Started) { if (view.AnalysisDisplayStyleId == ElementId.InvalidElementId) { CreateAVFDisplayStyle(doc, view); } SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(view); if (null == sfm) { sfm = SpatialFieldManager.CreateSpatialFieldManager(view, 1); } if (-1 != schemaId) { IList <int> results = sfm.GetRegisteredResults(); if (!results.Contains(schemaId)) { schemaId = -1; } } if (-1 == schemaId) { AnalysisResultSchema resultSchema1 = new AnalysisResultSchema(rnd.Next().ToString(), "Description"); schemaId = sfm.RegisterResult(resultSchema1); } FaceArray faces = s.Faces; Transform trf = Transform.Identity; foreach (Face face in faces) { int idx = sfm.AddSpatialFieldPrimitive(face, trf); IList <UV> uvPts = new List <UV>(); List <double> doubleList = new List <double>(); IList <ValueAtPoint> valList = new List <ValueAtPoint>(); BoundingBoxUV bb = face.GetBoundingBox(); uvPts.Add(bb.Min); doubleList.Add(value); valList.Add(new ValueAtPoint(doubleList)); FieldDomainPointsByUV pnts = new FieldDomainPointsByUV(uvPts); FieldValues vals = new FieldValues(valList); sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, schemaId); } transaction.Commit(); } } }
public static XYZ FindCentroid(Face face) { XYZ centroid; BoundingBoxUV bbuv = face.GetBoundingBox(); UV faceCenter = (bbuv.Min + bbuv.Max) / 2; centroid = face.Evaluate(faceCenter); return(centroid); }
private void GetGabarits(Face face) { BoundingBoxUV b = face.GetBoundingBox(); UV p = b.Min; UV q = b.Max; Height = Math.Abs(p.U) + Math.Abs(q.U); Width = Math.Abs(p.V) + Math.Abs(q.V); }
/// <summary> /// Compute the distance between two planar faces. /// </summary> /// <param name="face1">Face 1</param> /// <param name="face2">Face 2</param> /// <returns>Distance of the two planar faces</returns> private static double GetDistance(PlanarFace face1, PlanarFace face2) { BoundingBoxUV boxUV = face2.GetBoundingBox(); UV center = (boxUV.Max + boxUV.Min) * 0.5; XYZ centerPt = face2.Evaluate(center); IntersectionResult result = face1.Project(centerPt); return(face1.Project(centerPt).Distance); }
/// <summary> /// Return a string for a 2D bounding box /// formatted to two decimal places. /// </summary> public static string BoundingBoxString( BoundingBoxUV b) { //UV d = b.Max - b.Min; return(string.Format("({0},{1})", PointString(b.Min), PointString(b.Max))); }
/// <summary> /// Return a string for a 2D bounding box /// formatted to two decimal places. /// </summary> public static string BoundingBoxString( BoundingBoxUV b) { //UV d = b.Max - b.Min; return string.Format( "({0},{1})", PointString( b.Min ), PointString( b.Max ) ); }
public static XYZ ComputeNormalOfFace(Face face) { XYZ normal; BoundingBoxUV bbuv = face.GetBoundingBox(); UV faceCenter = (bbuv.Min + bbuv.Max) / 2; normal = face.ComputeNormal(faceCenter); return(normal); }
/// <summary> /// Simple test whether a given face normal vector /// points upwards in the middle of the face. /// </summary> static bool IsTopFace(Face f) { BoundingBoxUV b = f.GetBoundingBox(); UV p = b.Min; UV q = b.Max; UV midpoint = p + 0.5 * (q - p); XYZ normal = f.ComputeNormal(midpoint); return(Util.PointsUpwards(normal)); }
public static XYZ MidPoint(Face face) { BoundingBoxUV b = face.GetBoundingBox(); UV p = b.Min; UV q = b.Max; UV midparam = p + 0.5 * (q - p); XYZ midpoint = face.Evaluate(midparam); return(midpoint); }
internal static void ShowSolids(Document doc, IEnumerable <Solid> solids, IEnumerable <double> values) { SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(doc.ActiveView); if (sfm == null) { sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 1); } if (_SchemaId != -1) { IList <int> results = sfm.GetRegisteredResults(); if (!results.Contains(_SchemaId)) { _SchemaId = -1; } } if (_SchemaId == -1) { _SchemaId = registerResults(sfm, "ShowChanges", "Description"); } List <double> valueList = values.ToList(); int i = 0; foreach (Solid s in solids) { double value = valueList[i]; i++; FaceArray faces = s.Faces; Transform trf = Transform.Identity; foreach (Face face in faces) { int idx = sfm.AddSpatialFieldPrimitive(face, trf); IList <UV> uvPts = new List <UV>(); List <double> doubleList = new List <double>(); IList <ValueAtPoint> valList = new List <ValueAtPoint>(); BoundingBoxUV bb = face.GetBoundingBox(); uvPts.Add(bb.Min); doubleList.Add(value); valList.Add(new ValueAtPoint(doubleList)); FieldDomainPointsByUV pnts = new FieldDomainPointsByUV(uvPts); FieldValues vals = new FieldValues(valList); sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, _SchemaId); } } updateView(doc.ActiveView, StyleEnum.Faces); }
public static UV Evaluate(this BoundingBoxUV value, UV uv) { var u = uv.U; var v = uv.V; return(new UV ( value.Min.U * (1.0 - u) + value.Min.U * u, value.Min.V * (1.0 - v) + value.Min.V * v )); }
/// <summary> /// Return a string for this bounding box /// with its coordinates formatted to two /// decimal places. /// </summary> public static string BoundingBoxString( BoundingBoxUV bb, bool onlySpaceSeparator = false) { string format_string = onlySpaceSeparator ? "{0} {1}" : "({0},{1})"; return(string.Format(format_string, PointString(bb.Min, onlySpaceSeparator), PointString(bb.Max, onlySpaceSeparator))); }
/// <summary> /// Calculate and paint the attenuation /// values on the given face. /// </summary> public static void PaintFace( Face face, XYZ psource, AttenuationCalculator calc) { IList <UV> uvPts = new List <UV>(); IList <ValueAtPoint> uvValues = new List <ValueAtPoint>(); BoundingBoxUV bb = face.GetBoundingBox(); double umin = bb.Min.U; double umax = bb.Max.U; double ustep = 0.2 * (umax - umin); double vmin = bb.Min.V; double vmax = bb.Max.V; double vstep = 0.2 * (vmax - vmin); List <double> vals = new List <double>(1); vals.Add(0); XYZ psource2 = psource + _z_offset; for (double u = umin; u <= umax; u += ustep) { for (double v = vmin; v <= vmax; v += vstep) { UV uv = new UV(u, v); if (face.IsInside(uv)) { uvPts.Add(uv); XYZ ptarget = face.Evaluate(uv) + _z_offset; vals[0] = calc.Attenuation( psource2, ptarget); uvValues.Add(new ValueAtPoint(vals)); } } } FieldDomainPointsByUV fpts = new FieldDomainPointsByUV(uvPts); FieldValues fvals = new FieldValues(uvValues); _sfm.UpdateSpatialFieldPrimitive( _sfp_index, fpts, fvals, _schemaId); }
// convert a BoundingBoxUV to a Polygon private Polygon BoundingBoxToPolygon(BoundingBoxUV boundingBox) { List <XYZ> pnts = new List <XYZ>(); XYZ p1 = new XYZ(boundingBox.Min.U, boundingBox.Min.V, 0); XYZ p2 = new XYZ(boundingBox.Max.U, boundingBox.Min.V, 0); XYZ p3 = new XYZ(boundingBox.Max.U, boundingBox.Max.V, 0); XYZ p4 = new XYZ(boundingBox.Min.U, boundingBox.Max.V, 0); pnts.Add(p1); pnts.Add(p2); pnts.Add(p3); pnts.Add(p4); return(this.XYZList2Polygon(pnts, this.Exponent)); }
/// <summary> /// Determine appropriate field points and values /// to display the given greyscale bitmap image /// data on the given face. /// </summary> static void GetFieldPointsAndValues( ref IList <UV> pts, ref IList <ValueAtPoint> valuesAtPoints, //ref GreyscaleBitmapData data, Face face) { BoundingBoxUV bb = face.GetBoundingBox(); double umin = bb.Min.U; double umax = bb.Max.U; double ustep = (umax - umin) / _width; // data.Width double u = umin; double v = bb.Min.V; double vmax = bb.Max.V; double vstep = (vmax - v) / _height; // data.Height List <double> values = new List <double>(1); for (int y = 0; y < _height; ++y, v += vstep) // data.Height { Debug.Assert(v < vmax, "expected v to remain within bounds"); u = umin; for (int x = 0; x < _height; ++x, u += ustep) // data.Width { Debug.Assert(u < umax, "expected u to remain within bounds"); double brightness = _data.GetBrightnessAt(x, y); UV uv = new UV(u, v); pts.Add(uv); values.Clear(); values.Add(brightness); valuesAtPoints.Add( new ValueAtPoint(values)); } } }
private Reference FindTopMostReference(Element e) { Reference ret = null; Options opt = _doc.Application.Create.NewGeometryOptions(); opt.ComputeReferences = true; GeometryElement geo = e.get_Geometry(opt); foreach (GeometryObject obj in geo) { GeometryInstance inst = obj as GeometryInstance; if (inst != null) { geo = inst.GetSymbolGeometry(); break; } } Solid solid = geo.OfType <Solid>().First <Solid>(sol => null != sol); double z = double.MinValue; foreach (Face f in solid.Faces) { BoundingBoxUV b = f.GetBoundingBox(); UV p = b.Min; UV q = b.Max; UV midparam = p + 0.5 * (q - p); XYZ midpoint = f.Evaluate(midparam); XYZ normal = f.ComputeNormal(midparam); if (PointsUpwards(normal)) { if (midpoint.Z > z) { z = midpoint.Z; ret = f.Reference; } } } return(ret); }
public override Value Evaluate(FSharpList <Value> args) { FSharpList <Value> result = FSharpList <Value> .Empty; BoundingBoxUV bbox = null; object arg0 = ((Value.Container)args[0]).Item; Autodesk.Revit.DB.Face f; Reference faceRef = arg0 as Reference; if (faceRef != null) { f = dynRevitSettings.Doc.Document.GetElement(faceRef.ElementId).GetGeometryObjectFromReference(faceRef) as Autodesk.Revit.DB.Face; } else { f = arg0 as Autodesk.Revit.DB.Face; } if (f != null) { bbox = f.GetBoundingBox(); } result = FSharpList <Value> .Cons( Value.NewNumber(bbox.Max.V - bbox.Min.V), result); result = FSharpList <Value> .Cons( Value.NewNumber(bbox.Max.U - bbox.Min.U), result); result = FSharpList <Value> .Cons( Value.NewContainer(bbox.Max), result); result = FSharpList <Value> .Cons( Value.NewContainer(bbox.Min), result); //Fin return(Value.NewList(result)); }
public static void centerViewOnSheet(Viewport curVP, View curView, ViewSheet curSheet, Document m_doc) { //get center point of viewport XYZ vpCenter = null; Outline vpOutline = null; BoundingBoxUV sheetOutline = null; UV sheetCenter = new UV(); vpCenter = curVP.GetBoxCenter(); vpOutline = curVP.GetBoxOutline(); sheetOutline = curSheet.Outline; sheetCenter = (sheetOutline.Min + sheetOutline.Max) * 0.5; XYZ sheetCenterXYZ = new XYZ(sheetCenter.U, sheetCenter.V, 0); //move viewport to sheet center curVP.SetBoxCenter(sheetCenterXYZ); }
/// <summary> /// Retrieve the appropriate origin. /// </summary> /// <param name="bBox"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private Autodesk.Revit.DB.UV GetOffSet(BoundingBoxUV bBox, double x, double y) { return new Autodesk.Revit.DB.UV(bBox.Min.U + x * GOLDENSECTION, bBox.Min.V + y * GOLDENSECTION); }
GetOffset(BoundingBoxUV bBox, double x, double y) { return new UV(bBox.Min.U + x * GOLDENSECTION, bBox.Min.V + y * GOLDENSECTION); }
CalculateDistance(BoundingBoxUV bBox, int amount, ref double x, ref double y) { double xLength = (bBox.Max.U - bBox.Min.U) * (1 - TITLEBAR); double yLength = (bBox.Max.V - bBox.Min.V); //calculate appropriate rows numbers. double result = Math.Sqrt(amount); while (0 < (result - (int)result)) { amount = amount + 1; result = Math.Sqrt(amount); } m_rows = result; double area = xLength * yLength / amount; //calculate appropriate distance between the views. if (bBox.Max.U > bBox.Max.V) { x = Math.Sqrt(area / GOLDENSECTION); y = GOLDENSECTION * x; } else { y = Math.Sqrt(area / GOLDENSECTION); x = GOLDENSECTION * y; } }
private void Stream(ArrayList data, BoundingBoxUV bndBox) { data.Add(new Snoop.Data.ClassSeparator(typeof(BoundingBoxUV))); data.Add(new Snoop.Data.Uv("Min", bndBox.Min)); data.Add(new Snoop.Data.Uv("Max", bndBox.Max)); }