Message 1 of 7
Unable to get the 2D geometry of familyinstnace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am using the Revit SDK 2017 to read the 2D sheet data with following peace of code, here in case of element type as Autodesk.Revit.DB.Mesh I am getting whole 3D data of mesh. As I am parsing using the document as 3D view active. Can you help me to get the exact 2D geometry from this 3d view.
foreach (GeometryObject geomObj in geomElem)
{
// IList<XYZ> vertexArrList = new List<XYZ>();
if (geomObj is Solid)
{
Solid soliObj = geomObj as Solid;
if (soliObj != null)
{
// Wall solidWall = soliObj as Wall;
double zVal = 0.0;
bool isZvalSet = false;
{
foreach (Edge geomEdge in soliObj.Edges)
{
IList<XYZ> arrList = geomEdge.Tessellate();
foreach (XYZ array in arrList)
{
if (false == isZvalSet)
{
zVal = array.Z;
isZvalSet = true;
}
if ((zVal == arrList[0].Z) && (zVal == arrList[1].Z))
oVertexArrList.Add(array);
}
}
}
}
}
else if (geomObj is Line)
{
Line lineObjforInst = geomObj as Line;
if (lineObjforInst != null)
oVertexArrList = lineObjforInst.Tessellate();
}
else if (geomObj is Arc)
{
Arc arcObjforInst = geomObj as Arc;
if (arcObjforInst != null)
oVertexArrList = arcObjforInst.Tessellate();
}
else if (geomObj is NurbSpline)
{
NurbSpline numbSpline = geomObj as NurbSpline;
if (numbSpline != null)
oVertexArrList = numbSpline.Tessellate();
}
else if (geomObj is Ellipse)
{
Ellipse ellipseObjforInst = geomObj as Ellipse;
if (ellipseObjforInst != null)
oVertexArrList = ellipseObjforInst.Tessellate();
}
else if (geomObj is Autodesk.Revit.DB.Mesh)
{
Autodesk.Revit.DB.Mesh revitMesh = geomObj as Autodesk.Revit.DB.Mesh;
if (revitMesh != null)
oVertexArrList = revitMesh.Vertices;
}
else
{
GeometryInstance geoInst = geomObj as GeometryInstance;
if (geoInst != null)
{
GeometryElement geoElemofInst = geoInst.GetSymbolGeometry();
ProcessGeomElement(geoElemofInst, ref sbFileContent, ref oVertexArrList);
}
}