Hi, I finally had time to make this work !
I use the location instead of the project basepoint coordinates and here is the working code :
# -*- coding: utf-8 -*-
import Autodesk
from Autodesk.Revit.DB import UnitUtils
import webbrowser
from pyrevit import forms
doc = __revit__.ActiveUIDocument.Document
app = __revit__.Application
rvt_year = int(app.VersionNumber)
#-Get location and placeName infos-
currentLocation = doc.ActiveProjectLocation.GetSiteLocation()
impLat = currentLocation.Latitude
impLong = currentLocation.Longitude
placeName = currentLocation.PlaceName
#-Convert formula following revit version-
def convert_to_Degrees(value):
if rvt_year >= 2021:
from Autodesk.Revit.DB import UnitTypeId
return UnitUtils.ConvertFromInternalUnits(value, UnitTypeId.Degrees)
else :
from Autodesk.Revit.DB import DisplayUnitType
return UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_DECIMAL_DEGREES)
#-get Metric Lat/Long from Imperial Lat/Long-
metLat = convert_to_Degrees(impLat)
metLong = convert_to_Degrees(impLong)
#-Check if Longitude Value is default Revit value-
if str(metLong) == "-71.2580718994" :
msg = "L'emplacement de ce projet ne semble pas avoir été correctement défini ..."
sub_msg = "Cliquez sur Gérer > Emplacement pour résoudre ce problème en indiquant l'adresse exacte du projet "
forms.alert(msg, sub_msg, warn_icon=True)
#-if not, use the corrected value to make an alert form for the user-
else :
msg = "Allons voir ce qui se passe " + placeName
expanded = "Latitude : "+ str(metLat) + " & Longitude : " + str(metLong)
res = forms.alert(msg, expanded , cancel=True, warn_icon=False)
#-if user click on OK, open the webbrowser with the generated url with Metric Lat/Long -
if res :
url = "https://earth.google.com/web/@" + str(metLat) + "," + str(metLong) + ",5000d"
webbrowser.open(url)