Question

I have created a plugin that calculates the intersections between grids. The coordinates from the intersection calculation are using the basepoint position as the origin of the coordinates. I want to convert the coordinates to the Survey Point position. I tried to fetch the coordinates of the base point with this code:

ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_ProjectBasePoint);

FilteredElementCollector collector = new FilteredElementCollector(doc);
IList<Element> elements = collector.WherePasses(filter).ToElements();

foreach (Element element in elements)
{
    double x = element.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble();
    double y = element.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble();
    double elevation = element.get_Parameter  (BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble();
}

I wanted to use the basepoint coordinates to adjust the coordinates i found in my intersection calculation to use the Survey Point as a origin. But i can`t figure how to use the values from basepoint to adjust the coordinates. It seems the values in basepoint is not using survey point as origin, but maybe the internal coordinates. Or maybe i misunderstood the values in basepoint. Any pointers to what i can try ?

Was it helpful?

Solution

After a couple of days work i finally found my mistakes and the answer to my question. To anyone having the same problem as i, this is how i transformed the coordinates to the right coordinates:

  • The values i fetch from base point are the offset from the survey point, but my mistake is me being a European :p The values i get from the basepoint used feet as unit, while my project had milimeters as unit. So i created a convert function to convert all values i get from revit api(in my case: basepoint values and the grid intersect-function) to the project unit(milimeter). This is a great blog post on the subject http://thebuildingcoder.typepad.com/blog/2011/12/unit-conversion-and-display-string-formatting.html

  • The second thing i had to do is transform the coordinates using the basepoint offset. But the basepoint coordinatesystem may have a rotation. So i had to first rotate the coordinate

    double x = (pos.X * Math.Cos(angle)) - (pos.Y * Math.Sin(angle));
    double y = (pos.X * Math.Sin(angle)) + (pos.Y * Math.Cos(angle));
    

And then i could transform the coordinate:

new XYZ(position.X + projectBasePoint.X, newPos.Y + projectBasePoint.Y, 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top