Converting from Model Coordinates to Shared Coordinates


#1

For once I’m not looking for help but thought this might be helpful for others…

I’ve been working on this for a little while, I kept thinking I’d got there only to try it on another model and end up with the wrong values… I think though I’m finally there. It’s been a good exercise for me in understanding how this process works. Anyway I thought I’d post this here in case anyone is trying to do the same.

The key to this is knowing the location of a point in both model coordinates and shared coordinates. For this it’s easiest to use the Project Base Point - by extracting parameter data we can get it’s shared coordinates and by using the Coordinates.Basepoint node we can get the corresponding model coordinates.

Once you have this data you can then use it to define 2 coordinates systems - model and shared. The shared system needs to be rotated to match the project north rotation* and this can be done using the Coordinate System Rotate node.

Once both coordinate systems are defined you can then use the geometry transform node to convert from one to the other. The ‘from’ input is the coordinate system your element is reporting and the ‘context’ is the one you want to change it too.

Personally I’m trying to export coordinates to excel but there will I’m sure be other uses - my script is attached below.

*the only thing I still dont quite get is why, to get the correct translation, the rotation value needs to be 360-North Rotation and not simply the north rotation - maybe someone else can explain that.

There is some other info over on this thread which very much formed a starting point for me.

Cheers

K.Model Origin Survey Coordinates.dyn (23.8 KB)


Convert project coordinates to Survey
#2

Its looking good :slight_smile:

you might find the following python interesting, I cant remeber where I got it from, which is really bugging me as I usually keep a good note of where things are from, but its probably from this forum, from one of the many good people sharing their efforts

import clr
import math
# import Document Manager
clr.AddReference("RevitServices")
import RevitServices 
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

dataEnteringNode = IN
outData = []
outProjBasePt = []
outProjSurvPt = []
outProjLoc = []
ft2mm = 304.8

coll = FilteredElementCollector(doc)
basePt = coll.OfClass(BasePoint).ToElements()

projBasePt = None

for e in basePt:
	a = e.Category.Name
	if a == "Project Base Point":		
		pbpEW = e.LookupParameter("E/W")
		pbpNS = e.LookupParameter("N/S")
		pbpElev = e.LookupParameter("Elev")
		pbpAngle = e.LookupParameter("Angle to True North")
		outProjBasePt.append(round(pbpEW.AsDouble()*ft2mm,6))
		outProjBasePt.append(round(pbpNS.AsDouble()*ft2mm,6))
		outProjBasePt.append(round(pbpElev.AsDouble()*ft2mm,6))
		outProjBasePt.append(round(pbpAngle.AsDouble()*180/math.pi,6))
	elif a == "Survey Point":
		pspEW = e.LookupParameter("E/W")
		pspNS = e.LookupParameter("N/S")
		pspElev = e.LookupParameter("Elev")
		outProjSurvPt.append(round(pspEW.AsDouble()*ft2mm,6))
		outProjSurvPt.append(round(pspNS.AsDouble()*ft2mm,6))
		outProjSurvPt.append(round(pspElev.AsDouble()*ft2mm,6))

projLoc = doc.ActiveProjectLocation
origin = XYZ(0.0,0.0,0.0)

projPos = projLoc.get_ProjectPosition(origin)
if projPos == None:
	outProjLoc.append("No Project Position at origin point")
else:
	outProjLoc.append(round(projPos.EastWest * ft2mm,6))
	outProjLoc.append(round(projPos.NorthSouth * ft2mm,6))
	    	
OUT = [outProjLoc, outProjBasePt, outProjSurvPt]

Changing Active Project Location / Project Base Point
Location of linked file
#3

I keep threatening myself to learn Python… just haven’t found the time window as yet but I think it’s a must! #

Thanks for posting the code, I’ll take a look.


#4

no worries, thanks for your twitter post !

on your question on 360-angle, I think that might be because the API is measuring clockwise and revit displays the angle anticlockwise, or vice versa, I don’t really know just trying to think it through…


#5

It’s nice to be able to put something back into the dynamo community again - people here give so much so freely and I’ve learnt an awful lot. Still a long way to go mind!


#6

Hi Keith,

I have tried to set up my own script which extracts the project base points but I can’t seem to figure out how to convert them into Survey points using your method.

An help would be much appriciated

EXTRACT PILE COORDINATES.dyn (20.1 KB)


#7

@Kieran_Atherton have a look if this helps you out.