how can I extract the coordinates (X,Y,Z) of the family instance from Autodesk.Revit.DB.Location/LocationCurve/LocationPoint?

how can I extract the coordinates (X,Y,Z) of the family instance from Autodesk.Revit.DB.Location/LocationCurve/LocationPoint?

simonebehlings
Explorer Explorer
2,138 Views
6 Replies
Message 1 of 7

how can I extract the coordinates (X,Y,Z) of the family instance from Autodesk.Revit.DB.Location/LocationCurve/LocationPoint?

simonebehlings
Explorer
Explorer

From the family instance I can extract the location (element.Location), but I don't know the next step to get the coordinate values.


I need a result similar o this:


                                       Point.X =
element.Location ->    Point.Y=
                                        Poin.Z = 

 

(And these elements would be beams, columns, wall...) 

0 Likes
2,139 Views
6 Replies
Replies (6)
Message 2 of 7

MvL_WAG
Contributor
Contributor

As you stated, there are different aprouches for line base, and pointbased components.

 

If the elements location is stored as a Locationpoint, you cant get the point of the locationpoint. which is of type XYZ, which has the individually properties x,y,z.

 

if the elmenets location is stored as a locationcurve, you can get the curve of the locationcurve. From that curve you can get the endpoint with the getEndpoint method of the curve class. 

 

LocationPoint.Point

https://www.revitapidocs.com/2021.1/8d81892a-7863-cbec-9148-a0311f3bf2b6.htm

https://www.revitapidocs.com/2021.1/b03df3be-687a-2ac8-e28d-2e038ecac142.htm

So in code that looks something like below.

XYZ point = Location.Point;
double pointX = point.X;
double pointY = point.Y;
double pointZ = point.Z;

XYZ startpoint = Locationcurve.Curve.GetEndPoint(0);
double startpointX = startpoint.X;
double startpointY = startpoint.Y;
double startpointZ = startpoint.Z;

XYZ endpoint = Locationcurve.Curve.GetEndPoint(1);
double endpointX = startpoint.X;
double endpointY = startpoint.Y;
double endpointZ = startpoint.Z;

 

Message 3 of 7

sahin.ikbal
Advocate
Advocate

This is how you can get point and curve from family instance depending on whatever is available from the family instance.

 

Location.png

Message 4 of 7

simonebehlings
Explorer
Explorer

Thanks! I've already managed to solve most part of the problem.

I just couldn't extract the coordinates when the 'Location' property returns only 'Location', but with LocationCurve and LocationPoint I can.

0 Likes
Message 5 of 7

sahin.ikbal
Advocate
Advocate

@simonebehlings 

only 'Location' does not have any co-ordinates, so you can not get any spatial value from it.
This class is only used for manipulating spatially for move and rotate.

Message 6 of 7

simonebehlings
Explorer
Explorer

.

0 Likes
Message 7 of 7

simonebehlings
Explorer
Explorer
I saw that there were no properties related to coordinates in this class.
I'm thinking of another way to compare the position of two overlapping elements.
0 Likes