Is there a way to get the project Base Point, and if so, how? I can get the Project Location, but I need the base point (N/S, E/W, Elevation, Angle from North).
I found it in the elements.
There were two in my project - used Category.Name == "Project Base Point" to get the one I needed.
"E/W", "N/S", "Elev" and "Angle to True North" are in the ParametersMap.
I know this post is a few months old now but here is the code that i have used to get the Project Base Point:
ElementCategoryFilter siteCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_ProjectBasePoint); FilteredElementCollector collector = new FilteredElementCollector(doc); IList<Element> siteElements = collector.WherePasses(siteCategoryfilter).ToElements(); foreach (Element ele in siteElements) { Parameter paramX = ele.ParametersMap.get_Item("E/W"); double X = paramX.AsDouble(); Parameter paramY = ele.ParametersMap.get_Item("N/S"); double Y = paramY.AsDouble(); Parameter paramElev = ele.ParametersMap.get_Item("Elev"); double Elev = paramElev.AsDouble(); XYZ projectBasePoint = new XYZ(X, Y, Elev); }
Dear grahamcook,
as far as I see, it would be better to adress parameters language independent.
In my German Revit,
Parameter paramX = ele.ParametersMap.get_Item("E/W"); wouldn't work.
So one could better use
Parameter paramX = ele.ParametersMap.get_Item(BuiltInParameter.BASEPOINT_EASTWEST_PARAM);
Analogously, there is BASEPOINT_NORTHSOUTH_PARAM for "N/S" and BASEPOINT_ELEVATION_PARAM for the elevation.
Thanks,
Revitalizer
Hi Graham,
I think this is an important point that should be added to nearly every topic that is about getting parameters.
Since there is an international audience in this forum, localization may matter.
Best regards,
Revitalizer
Just updated my routines to include the BuiltInParameters as suggested. Had to slightly amend the parameter call given that get_Item cannot take a BuiltInParameter:
Parameter paramX = element.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM);
Hi Graham,
I usually use element.get_Parameter() instead of element.parametersmap.get_Item().
Parametersmap.get_Item() needs a key string since ParametersMap is a dictionary or hashtable.
get_Parameter() overload accepts both a string value and the BuitInParameter enumeration.
To adress parameters "in the international way", I would advice to use the last one.
Bye,
Revitalizer
There have been many updates to the Revit API since this post so the following code could be used where doc is a Document class:
XYZ projectBasePoint = new XYZ();
projectBasePoint = BasePoint.GetProjectBasePoint(doc).Position;