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: 

Finding coordinates relative to survey base point and project base point

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
senne.vande.sompele
4940 Views, 8 Replies

Finding coordinates relative to survey base point and project base point

Hi everybody,

 

I've been searching alot about this subject (and read alot) but can't find a solution.

I'm trying to find the coordinates for a point relative to the project base point.

I've found how to get them relative to the survey point as following:

ProjectLocation pl = doc.ActiveProjectLocation;
Transform ttr = pl.GetTotalTransform().Inverse;
 ProjectPosition projPosition = doc.ActiveProjectLocation.get_ProjectPosition(new XYZ(0, 0, 0));
LocationPoint loc = element.Location as LocationPoint;
if (loc != null)
{
    XYZ point = ttr.OfPoint(loc.Point);
}

this works perfectly even if I change the "The angle to the true north" but I can't find a way to get the position relative to the project base point.

Has someone have a solution for this?

 

greets

Senne

8 REPLIES 8
Message 2 of 9

define function  f(pt) = coordinate relative to surveypoint.

then  point-coordinate relative to project base point = f(pt) - f( project base point)

 

where 

XYZ location of the project base point .X  = project_base_point.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble());

XYZ location of the project base point .Y  = project_base_point.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble());

XYZ location of the project base point .Z  = project_base_point.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble());

Message 3 of 9

This is correct as long as your angle to the true north is 0°.

After you change this angle the coordinates you get back are not the same as the spot coordinates I have set

Message 4 of 9

It should be accurate, even with a rotated true north.

 

project_base.PNGproject_base_rotated.PNG

Message 5 of 9

Currently i'm doing the following

 

var basePoints = doc.NewFilteredElementCollector().OfClass<BasePoint>();
var projectPoint = basePoints.First(x => !x.IsShared);
var surveyPoint = basePoints.First(x => x.IsShared);


var px = projectPoint.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble();
var py = projectPoint.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble();
var pz = projectPoint.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble();
XYZ project = new XYZ(px, py, pz);
var sx = surveyPoint.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble(); var sy = surveyPoint.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble(); var sz = surveyPoint.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble(); XYZ survey = new XYZ(sx, sy, sz); var projectLocation = doc.ActiveProjectLocation; var surveyPosition = projectLocation.get_ProjectPosition(survey); survey = new XYZ(-surveyPosition.EastWest, -surveyPosition.NorthSouth, -surveyPosition.Elevation);

ProjectLocation pl = doc.ActiveProjectLocation;
Transform ttr = pl.GetTotalTransform().Inverse;

LocationPoint loc = element.Location as LocationPoint;
if (loc != null)
{
XYZ point = ttr.OfPoint(loc.Point);
XYZ projectPoint = ttr.OfPoint(project);
var x = Math2.FeetToMeters(point.Y - projectPoint.X);
var y = Math2.FeetToMeters(point.Y - projectPoint.Y);
var z = Math2.FeetToMeters(point.Z - projectPoint.Z)
}

But this gives me incorrect values for x,y,z

Do you see what i'm doing wrong

 

Message 6 of 9

I did some testing, and discovered that the spotcoordinate with origin Project Base doesn't change if the angle to True North changes.

 

So it's simpler than I thought. The coordinate relative to project base point is in project coordinates. (no Transform required).

 

XYZ  coord_to_proj_base  =  loc.Point.Subtract( project )

Message 7 of 9

hi I tried that but I think I'm doing something wrong here's the code i'm using:

 

var basePoints = doc.NewFilteredElementCollector().OfClass<BasePoint>();
var projectPoint = basePoints.First(x => !x.IsShared);

var px = projectPoint.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble();
var py = projectPoint.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble();
var pz = projectPoint.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble();
XYZ project = new XYZ(px, py, pz);

LocationPoint loc = element.Location as LocationPoint;

 XYZ projectPoint = loc.Point.Subtract(project);

Capture.PNG

Message 8 of 9

a new way to determine the coordinates of the project base point:

 

                XYZ project = projectPoint.get_BoundingBox().Min;

Message 9 of 9

Thank you very much that was the solution!

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community