Search code examples
revit-apirevitpythonshellpyrevit

Project Base Point & Survey Point in Revit 2020


I am trying to read Linked Project Base Point/Survey Point in Revit 2020 I am trying to get "E/W",'N/S', "Elev", 'Angle to True North' from BasePoint Class in Revit 2020. The same can be acquired from Revit 2019.

** Sample code for Revit 2019 to extract Project Base Point/Survey Point

        link_base_pt = link_coll.OfClass(BasePoint).ToElements() 
        # print(link_base_pt)
        
        link_Projbase_pt = link_base_pt[1]            
        linkProjBasePt = []   
        a = link_Projbase_pt.Category.Name
        # print(a)
        if a  == 'Project Base Point':
            lpbpEW = link_Projbase_pt.LookupParameter('E/W')
            lpbpNS = link_Projbase_pt.LookupParameter('N/S')
            lpbpElev = link_Projbase_pt.LookupParameter("Elev")
            lpbpAngle = link_Projbase_pt.LookupParameter('Angle to True North')
            linkProjBasePt.append(format_length(lpbpEW.AsDouble()))
            linkProjBasePt.append(format_length(lpbpNS.AsDouble())) 
            linkProjBasePt.append(format_length(lpbpElev.AsDouble())) 
            linkProjBasePt.append(str(round(lpbpAngle.AsDouble() * 180/math.pi,6)))   
        linkProjBasePt_final = linkProjBasePt
        # print(linkProjBasePt_final)
        
        link_SurvPt = link_base_pt[0]   
        linkSurveyPt = []
        b = link_SurvPt.Category.Name
        # print(b)
        if b  == 'Survey Point':
            lpbpEW = link_SurvPt.LookupParameter('E/W')
            lpbpNS = link_SurvPt.LookupParameter('N/S')
            lpbpElev = link_SurvPt.LookupParameter("Elev")

            linkSurveyPt.append(format_length(lpbpEW.AsDouble()))
            linkSurveyPt.append(format_length(lpbpNS.AsDouble())) 
            linkSurveyPt.append(format_length(lpbpElev.AsDouble())) 

        linkSurveyPt_final = linkSurveyPt
        # print(linkSurveyPt_str)   **

Solution

  • This worked for me

    # get revit link instance from selection
    linkInstance = UnwrapElement(IN[0]) 
    
    # get link document and project locations from linked document
    linkDoc = linkInstance.GetLinkDocument()
    locationLinkSet = linkDoc.ProjectLocations
    
    modulus = 0.0174532925199433 #modulus to convert to degrees (π/180)
    inchToMm = 25.4 #to convert to mm
    footToMm = 12 * inchToMm  #to convert to mm
    
    #looking for "Internal" Project Location
    for projectLocation in locationLinkSet:
        if projectLocation.Name == "Internal":
            origin = Autodesk.Revit.DB.XYZ(0, 0, 0)
    
            #get the project position
            pp = projectLocation.GetProjectPosition(origin)
            angle = (pp.Angle / modulus)   #Angle from True North, convert to degrees  
            eastWest = pp.EastWest  * footToMm     #East to West offset
            northSouth = pp.NorthSouth * footToMm   #North to south offset
            elevation = pp.Elevation * footToMm    #Elevation above ground level