Hi All,
I am new to use RevIT API . I need to know about following things :
1) How to calculate model group elements area using Revit API ?
2) Is this possible using ExtrusionAnalyzer ? If yes then how we can achieve this ?
As i know ExtrusionAnalyzer needs a solid type object to draw the shadow, correct me if i am wrong.
From a model group i have extracted the elements that belongs to the model group. Now the problem is that extracted elements can have different types not necessarily solid type.
Let me know if anyone have any idea about this.
Thanks
Dear Vyom Dixit,
It really all depends on what type of elements you are talking about.
Best regards,
Jeremy
Hi Jeremy,
Thanks to your response. Regarding to question, I have model group that can have some equipments like Freezer,WorkTable or any Specility Equipment,furniture etc. I want to calculate total occupied areas of these equipments that belongs to the model group. Can you give me any way to achieve this ?
Thanks
Vyom Dixit
Dear Vyom Dixit,
Once you put it like that, I understand what you need.
I have in fact solved that exact issue, for my room editor app, to determine boundary loops for equipment and furniture family instances:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.21
In that case, I did in fact use the ExtrusionAnalyzer class to determine the closed loops.
In my case, though, it would probably have been easier just using the 2D plan view of the family instances.
For areas, though, the extrusion analyser is probably the right way to go.
At least it is a very generic solution.
As you say, though, it does require a solid.
Cheers,
Jeremy
Dear Vyom Dixit,
I expanded a bit on my initial answer and published a summary of this thread on The Building Coder:
You might want to check out the enhanced answer there as well.
Thank you!
Cheers,
Jeremy
Hi Jeremy,
Many thanks to your quick response.I have reviewed your post as you mentioned in your last reply. In my case, i don't think extrusion analyser approach would work for all the model group elements becuase i am getting exception to union some solids that belong to family instance. So, i want to use that approach you have mentioned in your post : "using 2D plan view of the family instances". Can you suggest this approach in steps not the code ?
Thanks
Vyom Dixit
Dear Vyom Dixit,
Please note that I ran into such exceptions when performing the Boolean unions as well and added exception handlers to take care of those cases anyway.
The extrusion handler is fed with 3D solids retrieved from the family instances in a 3D view.
If you retrieve their geometry via a 2D plan view instead, you will get other results and other geometry, presumably mainly consisting of curves.
Grab those curves and do what thou wilt.
Cheers,
Jeremy
Hi Jeremy,
I followed as you suggested, but the area i am getting is not correct. I am putting here my code block, suggest me where i am missing something or doing anything wrong in the approach. The current view of the revit model is plan view. Please have a look on below code and suggest me where i am doing anything not correctly.
I have taken reference from your below post -
http://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html
Code Block :
public static double GetElementOccupiedAreaByGeometry(Document doc, Element component)
{
List<List<UV>> polygons = new List<List<UV>>();
double elmentArea = 0;
Options geomOption = doc.Application.Create.NewGeometryOptions();
geomOption.View = doc.ActiveView;
GeometryElement geoElement = component.get_Geometry(geomOption);
foreach (GeometryObject geoObject in geoElement)
{
if (geoObject.GetType() == typeof(GeometryInstance))
{
GeometryInstance geomInst = geoObject as GeometryInstance;
foreach (GeometryObject gObject in geomInst.GetInstanceGeometry())
{
if (gObject is Arc)
{
Arc arc = gObject as Arc;
if (arc != null)
{
List<XYZ> points = arc.Tessellate().ToList();
if (points.Count > 0)
{
polygons.Add(GetPolygon(points));
}
}
}
}
}
}
// get signed polygon area by each polygon UV list.
foreach (List<UV> polygon in polygons)
{
double area = GetSignedPolygonArea(polygon);
if (Math.Abs(elmentArea) < Math.Abs(area))
{
elmentArea = area;
}
}
return elmentArea;
}
private static List<UV> GetPolygon(List<XYZ> polygon)
{
List<UV> uvGroup = new List<UV>();
foreach (XYZ point in polygon)
{
uvGroup.Add(new UV(point.X, point.Y));
}
return uvGroup;
}
// this algo taken from "http://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html"
private static double GetSignedPolygonArea(List<UV> p)
{
int n = p.Count;
double sum = p[0].U * (p[1].V - p[n - 1].V);
for (int i = 1; i < n - 1; ++i)
{
sum += p[i].U * (p[i + 1].V - p[i - 1].V);
}
sum += p[n - 1].U * (p[0].V - p[n - 2].V);
return 0.5 * sum;
}
Please let me know your suggestions.
Thanks
Vyom Dixit
Dear Vyom Dixit,
What is not correct? What is the result, and what are you expecting? You are aware that all Revit database length units are in feet, I hope?
Cheers,
Jeremy
Hi Jeremy,
My revit model units are in feet and i am also handling unit conversion. I just want to confirm that Are we fine with only element
"Arc" type object ( or we need to cosider Line/Solid type object also ) while traversing the element geometry. As i am trying to get area of speciality equipment like - "Hand Sink". It's dimension is as mentioned below. So area should be accordingly.
Length = 1feet 2 inch
width = 0 feet 10 inch
Thanks
Vyom Dixit
Dear Vyom Dixit,
The easiest way to handle arcs and other curved elements is to tessellate them into straight line segments.
The Revit API does that for you automatically, if you want.
Techniques for handling this are demonstrated in multiple places on The Building Coder, including the sequence of posts that I already pointed out to you.
Cheers,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.