Getting the base point of the ActiveDocument
Not applicable
09-18-2020
11:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attempting to get the base point of the Revit document.
I am attempting to access the ActiveDocument property, but I am not sure what object I must instantiate (I tried instantiating the ActiveDocument object, but it's not a type, it's a property, yet I am not sure why I am getting this error then (First time working in C#):
1. Error (CS0120): An object reference is required for the non-static field, method, or property 'Autodesk.Revit.UI.Events.CommandEventArgs.ActiveDocument.get' (line 6
using DB = Autodesk.Revit.DB; using UI = Autodesk.Revit.UI;
DB.Document activeDoc = Autodesk.Revit.UI.Events.CommandEventArgs.ActiveDocument; DB.FilteredElementCollector locations = new DB.FilteredElementCollector(activeDoc).OfClass(typeof(DB.BasePoint)); foreach (var locationPoint in locations) { DB.BasePoint basePoint = locationPoint as DB.BasePoint; if (basePoint.IsShared == true) { //this is the survey point DB.Location svLoc = basePoint.Location; A = basePoint.get_Parameter(DB.BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble(); //projectSurvpntY = basePoint.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble(); //projectSurvpntZ = basePoint.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble(); } }
Your help would be much appreciated.
Cross-posted here as well:
https://discourse.mcneel.com/t/c-getting-the-base-point-of-the-document/108681