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

How do i retrieve the start and end points of an element?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
jmadeley37KVE
208 Views, 2 Replies

How do i retrieve the start and end points of an element?

Hi all,

 

I've inserted an Adaptive Family Instance in my model using the Revit API and now need to add some annotations on a view. The adaptive family required a start and end point (P1 and P2) to insert, is there a way I can convert the element.Location prooperty to a LocationCurve in Revit 2023?

 

I have tried casting:

 

var locationCurve = element.Location as LocationCurve;

 

but this throws a Null Reference Exception. If anyone knows a way to do this in my version of Revit I would really appreciate the help 🙂

 

Thanks

Jack

2 REPLIES 2
Message 2 of 3

Hi Marty,

 

Thanks for the above. I have previously tried casting to a LocationCurve property, but this seems to throw a NullReferenceException. I have checked that the element.Location property exists and is not null, so it looks like the issue is the actual casting.

 

Is there any other way i could do this?

 

Thanks

Jack

Message 3 of 3

After doing some digging through the documentation, I think I have come up with a way to get the co-ordinates.

 

If you use the method GetFamilyPointPlacementReferences() on the element, you are returned an IList<FamilyPointPlacementReference> object. With this list you can use a Linq Select statement to get the Location object and inside the transform is the origin XYZ.

 

The code looks like this:

 

var references = element.GetFamilyPointPlacementReference().Select(x => x.Location.Origin)

 

The references object is a series of XYZ points that we can then use for any further logic. It looks like the FamilyPointPlacementReference's that are returned from the GetFamilyPointPlacementReference() method have a name which in my case were "END1" and "END2". In my case this worked perfectly for finding the start and end points.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community