- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Introduction
First let me introduce what I understand on the geometry of a FamilyInstance. A FamilyInstance have GeometryInstance which can give you two kind of Geometry:
- Symbol : The geometry of the FamilyInstance in the Family coordinates, so you need to apply the Transform of the Family to get the Geomety you see in Model.
- Instance : The Geometry you see in Model in the correct position, but it doesn't compute reference so I banned it.
Some links which can be useful :
https://www.revitapidocs.com/2016/d3567707-4f77-5ed8-16f4-6d57411cf41b.htm
https://thebuildingcoder.typepad.com/blog/2010/02/retrieving-column-and-stair-geometry.html
The problem with columns
In all kind of objects I tested, what I explained with Symbol geometry which needs to be Transformed is True, BUT for columns it's like the Transform is already made in the Symbol geometry!
I must precise that I tested with custom columns in my own template, but I tested too with the same result in Revit base template "Systems-Default_Metric.rte" using Revit base Family "UC-Universal Column-Column".
What works for me (for now)
I created a method which identify if it's a column to decide if the Transform must be applied or not, but it doesn't look robust.
/// <summary>
/// Get the geometry of an element
/// </summary>
public static List<Solid> GetGeometry(this Element elem, Options geomOptions)
{
//var doc = elem.Document;
var solidList = new List<Solid>();
if (geomOptions != null)
{
var geoElem = elem.get_Geometry(geomOptions);
if (geoElem != null)
{
foreach (var geomObj in geoElem)
{
if (geomObj is Solid obj) solidList.Add(obj);
//handle_geometry_instances - START
if (geomObj is GeometryInstance geoInst)
{
//InstanceGeometry return the TRUE geometry BUT it doesn't compute Reference so don't use it !!!!!
var geoE = geoInst.GetSymbolGeometry();
if (elem.TransformThisObjectGeometryToGetTheTrueGeometry()) geoE = geoInst.GetSymbolGeometry(((FamilyInstance)elem).GetTotalTransform());
foreach (var gObj2 in geoE)
{
var geoSolid2 = gObj2 as Solid;
if (geoSolid2 != null) solidList.Add(geoSolid2);
}
}
//handle_geometry_instances - END
}
}
}
return solidList;
}
/// <summary>
/// Use This method to determine if an Element Geometry need to be Transformed using (Element as FamilyInstance).GetTotalTransform()
/// </summary>
/// <returns>True if need to be transformed</returns>
public static bool TransformThisObjectGeometryToGetTheTrueGeometry(this Element elem)
{
var cat = (BuiltInCategory)elem.Category.IdAsInt();
return elem is FamilyInstance
&& cat != BuiltInCategory.OST_Columns
&& cat != BuiltInCategory.OST_StructuralColumns;
}
Question
Am I missing something? If not, is there others kind of Family with this Geometry behavior? Is it possible to identify them with a more robust approach?
It would be awesome if my method "GetGeometry" abstract this behavior.
Thanks
Solved! Go to Solution.
Developer Advocacy and Support +