Revit MEP Forum
Welcome to Autodesk’s Revit MEP Forums. Share your knowledge, ask questions, and explore popular Revit MEP topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Element.Location to XYZ

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
5813 Views, 4 Replies

Element.Location to XYZ

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?

4 REPLIES 4
Message 2 of 5
fabiosato
in reply to: Anonymous

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.

EESignature

Message 3 of 5
Anonymous
in reply to: Anonymous

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!!

Message 4 of 5
Anonymous
in reply to: Anonymous

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); }
Message 5 of 5
Houba3314
in reply to: Anonymous

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.

Post to forums  

Autodesk Design & Make Report