Message 1 of 5

Not applicable
03-26-2019
12:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
One easy way to get a pretty good approximate value would be to tessellate the curve and determine the minimum and maximum resulting vertex coordinates:
https://apidocs.co/apps/revit/2019/f95f3199-3251-c708-c5a3-a0e9ef95ecfa.htm
Hi jeremytammik
It works for me.
Thank you
List<XYZ> lstPts = new List<XYZ>();
foreach (Curve cv in cl)
{
lstPts.AddRange(cv.Tessellate());
}
List<XYZ> tmp = lstPts.OrderBy(x => x.Z).ToList();
List<XYZ> tmp1 = lstPts.OrderBy(x => x.X).ToList();
double height = Math.Abs(tmp[0].Z - tmp[tmp.Count - 1].Z);
double width = Math.Abs(tmp1[0].X - tmp1[tmp1.Count - 1].X);
Thank you for confirming and sharing!
I decided to add something similar to The Building Coder samples for future reference.
To make it more generic, I implemented an extension method ExpandToContain( IEnumerable<XYZ> ) on the bounding box, and use it like this:
public static BoundingBoxXYZ GetBoundingBox( CurveLoop curveLoop ) { List<XYZ> pts = new List<XYZ>(); foreach( Curve c in curveLoop ) { pts.AddRange( c.Tessellate() ); } BoundingBoxXYZ bb = new BoundingBoxXYZ(); bb.Clear(); bb.ExpandToContain( pts ); return bb; }
Can you confirm that this works for you as well?
Thank you!
Here are the entire diffs (unfortunately including lots of superfluous whitespace modifications):
https://github.com/jeremytammik/the_building_coder_samples/compare/2019.0.145.12...2019.0.145.13
Cheers,
Jeremy
Hi jeremytammik,
I tried your code in my project.
It is working without any error and returns expected result.
Thank you.