Vous avez des coordonnées, vous voulez les convertir vers un autre système de coordonnées, voici quelques exemples...
- Pour convertir des coordonnées Topographique en coordonnées Interne (relative)
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
toList = lambda x : x if hasattr(x, '__iter__') else [x]
lst_DSPt = toList(IN[0])
out = []
for pt in lst_DSPt:
pt = pt.ToXyz()
#translate point from Shared coordinates to Internal
translatedpointB = doc.ActiveProjectLocation.GetTotalTransform().OfPoint(pt)
out.append(translatedpointB.ToPoint())
OUT = out
- Pour convertir des coordonnées Interne (relative) en coordonnées Topographique
import sys
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
toList = lambda x : x if hasattr(x, '__iter__') else [x]
lst_DSPt = toList(IN[0])
out = []
for pt in lst_DSPt:
pt = pt.ToXyz()
#translate point from Internal to Shared coordinates
translatedpointB = doc.ActiveProjectLocation.GetTotalTransform().Inverse.OfPoint(pt)
out.append(translatedpointB.ToPoint())
OUT = out
- Pour convertir des coordonnées de Projet en coordonnées Topographique (avec un Offset)
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
pt = IN[0].ToXyz()
# get Offset beetween internal and Base Project Point
basePt = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ProjectBasePoint).FirstElement()
ele = basePt.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble()
baseTranslatedPt = XYZ(0,0,ele) - doc.ActiveProjectLocation.GetTotalTransform().Inverse.OfPoint(XYZ.Zero)
# calculation
translatedpointA = doc.ActiveProjectLocation.GetTotalTransform().Inverse.OfPoint(pt) + baseTranslatedPt
OUT = translatedpointA.ToPoint(), "Offset BasePoint/Internal : {}".format(baseTranslatedPt.ToPoint().Z)
-
Pour convertir des coordonnées Topographique en coordonnées de
Projet
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
toList = lambda x : x if hasattr(x, '__iter__') else [x]
lst_DSPt = toList(IN[0])
out = []
basePt = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ProjectBasePoint).FirstElement()
ew = basePt.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM).AsDouble()
ns = basePt.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).AsDouble()
ele = basePt.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM).AsDouble()
rot = basePt.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM).AsDouble()
locBasePoint = XYZ(ew, ns, ele)
# alternative
# locBasePoint = basePt.get_BoundingBox(None).Min
#
pos = doc.ActiveProjectLocation.GetProjectPosition( XYZ.Zero )
posPt = XYZ( pos.EastWest, pos.NorthSouth , pos.Elevation )
vect = locBasePoint - posPt
#get Transform Survey
transfSurvey = doc.ActiveProjectLocation.GetTotalTransform()
for pt in lst_DSPt:
pt = pt.ToXyz()
out.append(transfSurvey.OfPoint(pt).Subtract(vect).ToPoint())
OUT = out
- Pour convertir des coordonnées Interne (relative) en coordonnées Projet
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
toList = lambda x : x if hasattr(x, '__iter__') else [x]
lst_DSPt = toList(IN[0])
out = []
projectPoint = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ProjectBasePoint).FirstElement()
projectXyz = projectPoint.get_BoundingBox(None).Min
for pt in lst_DSPt:
pt = pt.ToXyz()
out.append(pt.Subtract(projectXyz).ToPoint() )
OUT = out
- Obtenir les informations sur les sites d'un modèle
sites = FilteredElementCollector(doc).OfClass(ProjectLocation)
for site in sites:
pos = site.GetProjectPosition( XYZ.Zero )
posPt = XYZ( pos.EastWest, pos.NorthSouth , pos.Elevation )
siteLocation = site.GetSiteLocation()
Note mise à jour Revit 2021 :
À partir de Revit 2021, l'API propose 2 nouvelles Classes :
- InternalOrigin
-
BasePoint
import clr
import sys
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
# Get document information from Revit
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
bp_origin = BasePoint.GetProjectBasePoint(doc).Position.ToPoint()
bp_shared = BasePoint.GetProjectBasePoint(doc).SharedPosition.ToPoint()
io_origin = InternalOrigin.Get(doc).Position.ToPoint()
io_shared = InternalOrigin.Get(doc).SharedPosition.ToPoint()
sp_origin = BasePoint.GetSurveyPoint(doc).Position.ToPoint()
sp_shared = BasePoint.GetSurveyPoint(doc).SharedPosition.ToPoint()
OUT = [["io_origin",io_origin],
["io_shared", io_shared],
["bp_origin" , bp_origin],
["bp_shared",bp_shared],
["sp_origin" , sp_origin],
["sp_shared" , sp_shared]]
Pour cela il faut désormais utiliser le bouton "Replacer le
Projet".
Bonjour, super présentation. Merci
RépondreSupprimerSerait possible que dans le code python, il puisse reconnaitre des coordonnées provenant d'une liste de coordonnées ? j'ai essayé j'ai l'impression que ca ne fonctionne pas.
Ok, je vais rajouter un exemple pour les listes en entrées
Supprimer