GeometryObject Class. Autodesk 2014 Platform API
Advertisement
Advertisement
The sample code follows:
Code Region 20-2: Retrieving faces and edges
1.
private void
GetFacesAndEdges(Wall wall)
2. {
3. String faceInfo = "" ;
4.
5. Autodesk.Revit.DB.Options opt =
new
Options();
6. Autodesk.Revit.DB.GeometryElement geomElem = wall.get_Geometry(opt);
7.
foreach
(GeometryObject geomObj
in
geomElem)
8. {
9. Solid geomSolid = geomObj
as
Solid;
10.
if
(
null
!= geomSolid)
11. {
12.
int
faces = 0;
13.
double
totalArea = 0;
14.
foreach
(Face geomFace
in
geomSolid.Faces)
15. {
16. faces++;
17. faceInfo += "Face " + faces + " area: " + geomFace.Area.ToString() + "\n" ;
18. totalArea += geomFace.Area;
19. }
20. faceInfo += "Number of faces: " + faces + "\n" ;
21. faceInfo += "Total area: " + totalArea.ToString() + "\n" ;
22.
foreach
(Edge geomEdge
in
geomSolid.Edges)
23. {
24. // get wall's geometry edges
25. }
26. }
27. }
28. TaskDialog.Show( "Revit" , faceInfo);
29. }
GeometryObject Class
The indexed property Element.Geometry[] can be used to pull the geometry of any model element (3D element). This applies both to system family instances such as walls, floors and roofs, and also to family instances of many categories, e.g. doors, windows, furniture, or masses.
The extracted geometry is returned to you as Autodesk.Revit.DB.GeometryElement. You can iterate through the geometry members of that element by using the GetEnumerator() method.
Typically, the objects returned at the top level of the extracted geometry will be one of:
•
Solid – a boundary representation made up of faces and edges
•
Mesh – a 3D array of triangles
•
Curve – a bounded 3D curve
• Point – a visible point datum at a given 3D location
•
PolyLine – a series of line segments defined by 3D points
•
GeometryInstance – an instance of a geometric element positioned within the element
Download
Advertisement