Reputation: 3
**this is the copy of the post in Revit API forums
Hi,
I have multiple instances of cylinder based family in my project. The instances were created using the following code line:
FamilyInstance element = document.Create.NewFamilyInstance(location, symbol, StructuralType.NonStructural);
The location of the family instance is composed of X and Y coordinates while the Z coordinate remains 0.0
e.g (-6.2, 65.6, 0.0).
The length of the cylindrical family instances is controlled by a Depth parameter, Such that where one instance ends (in Z direction ) another instance starts.
Now after the creation of family instances i want to Retrieve the XYZ coordinates of the family insertion point, which i do with the following code:
// remove duplicate values from geo_famtyp_names list
List<string> distinct_geo_famtyp_names = geo_famtyp_names.Distinct().ToList();
//ITERATE OVER EACH TYPE NAME PRESENT IN THE LIST AND RETRIEVE A COLECTION OF ELEMENTS AND THEN PERFORM OTHER FUNCTIONS
foreach (string typename in distinct_geo_famtyp_names)
{
List<XYZ> positions = new List<XYZ>();
var paramId = new ElementId(BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM);
var fam_type = String.Format("{0}: {1}", "BAUER_Fam_GeologyLayer", typename);
var rule = ParameterFilterRuleFactory.CreateEqualsRule(paramId, fam_type, true);
var filter = new ElementParameterFilter(rule);
var elem_collec = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).WherePasses(filter).ToList();
// GET A LIST OF POSITIONS FOR EACH ELEMENT OF A SPECIFIC FAM TYPE
foreach (FamilyInstance el in elem_collec)
{
XYZ elem_pos = ((LocationPoint)el.Location).Point;
if (!(positions.Contains(elem_pos)))
{
positions.Add(elem_pos);
}
}
The problem is that with this code, I am getting only the X and Y coordinate values for each Family instance while the Z coordinate remains 0.0
After getting the XYZ coordinates i have to create a topography surface which joins family instances of same Family types.
Any guideance on how to retrieve the value of z coordinate as well, would be greatly helpful .
Cheers,
Upvotes: 0
Views: 534
Reputation: 8339
Answered by RPTHOMAS108 in the Revit API discussion forum thread on Getting XYZ coordinates of Cylindrical family instances: The family is an adaptive component; strange, it has lost its location point reference for Z. Probably due to how it was authored, i.e., point not constrained correctly in family. If you are stuck with a problem to solve then you can refer to the BoundingBox
Z values in short term.
Upvotes: 0