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
Solved! Go to Solution.
Solved by FAIR59. Go to Solution.
Solved by FAIR59. Go to Solution.
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());
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
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
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 )
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);
a new way to determine the coordinates of the project base point:
XYZ project = projectPoint.get_BoundingBox().Min;