I'm trying to create a `List<XYZ>` or `XYZ[ ]` from a `List<Element>`. Both `Location` and `XYZ` are members of the Autodesk.Revit.DB namespace, but there doesn't seem to be a conversion method. Does anyone know of one, or have you created something that may be able to help me out?
Solved! Go to Solution.
Hello,
Maybe you should try Dynamo forums?
Fábio Sato
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Someone answered this for me on StackOverflow: Location to XYZ
Also, prior to that, I was able to create this algorithm:
var fecAllElements = new FilteredElementCollector(pDoc).OfClass(typeof(FamilyInstance));
foreach (Element pElt in fecAllElements.ToList()) { lstElts.Add(pElt); }
arValvePoints = new Location[lstElts.Count];
for (itr = 0; itr < lstElts.Count; itr++) arValvePoints[itr] = lstElts[itr].Location; //PUT THEIR LOCATION(X,Y,Z) IN AN ARRAY foreach (LocationPoint loc in arValvePoints) //GET MY (X,Y,Z)s FROM THE ARRAY... { XYZ newLoc = new XYZ(); newLoc = loc.Point; lstXYZ.Add(newLoc); }
Thanks to everyone that helped, and I hope this can help someone else!!
Just saw my old code and it made me a little nauseas. Let's maybe do this instead:
List<FamilyInstance> lElts = new FilteredElementCollector(m_pDoc).OfClass(typeof(FamilyInstance)).
Cast<FamilyInstance>().ToList(); List<XYZ> lLocations = new List<XYZ>(); foreach (var pFam in lElts) { LocationPoint pPoint = pFam.Location as LocationPoint; if (pPoint != null) lLocations.Add(pPoint.Point); }
hello im having a problem im trying to place family instances and if there s a familyinstance already i should skip it here is my code even though i add the location to the list when i check if it contains the locations it s not entering a the condition
Can't find what you're looking for? Ask the community or share your knowledge.