Wall and slab XYZ Coordinates From Revit to Dynamo

I am currently working on a project that requires me to extract xyz coordinates of walls from revit to dynamo. From here I want to execute a serious of list operations, one of which requires me to see if grid coordinates from a grid I created in dynamo clashes with the wall coordinates from revit and if so change them to 0.

My question is, how do I extract the wall coordinates of a building from revit to dynamo?

Do you need all eight points from each wall?

I really only need the coordinates for the length of the wall

In that case you can use the Element.Location from Clockwork package:

1 Like

Hi Einar

I have tried your approach above to extract coordinates for structural foundations and slabs, but it’s not returning any results. Could you please advise maybe a different approach?

Many thanks.
Fenn

How about using a Python script to work out the end points:

import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
adoc = doc.ActiveView

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
walltouses = UnwrapElement(IN[0])

endpoints = []

for f in walltouses:
	endpoints.append([f.Location.Curve.GetEndPoint(0), f.Location.Curve.GetEndPoint(1)])

#Assign your output to the OUT variable.
OUT = (endpoints)

Just create a Python script note and copy the above scipt into it, then connect the ‘Elements’ from the ‘All Elements of Category’ node to it.

1 Like

Hi Kevin

Thanks for that and your prompt response. I am going to give it a go.

Kind regards,
Fenn

Note that the code will only work on walls - finding the wall endpoints (wasn’t that what you wanted to do?), it won’t work on slabs and other objects.

Also, I forgot that the script will return the XYZ values in decimal feet, if you want milimetres then you need to multiple by 304.8.

Change the for loop to this to do the job:

for f in walltouses:
	endpoints.append([f.Location.Curve.GetEndPoint(0) * 304.8, f.Location.Curve.GetEndPoint(1) * 304.8])

Thanks Kevin

Your Python script yields results for structural framing and walls, but I am actually trying to find a way to get XYZ coordinates for slabs/floors and structural foundations. Any ideas?

Can you provide a screenshot or sketch where the coordinates you are interested in are marked?

Einar

Please see the attached sketch.

Thanks
Fenn

One way to do it is

  • get the elements faces with Element.Faces
  • filter out the top or bottom surface with FilterByBoolMask and Surface.NormalAtParameter == Zaxis
  • get perimeter curves
  • get startpoints of perimeter curves

Einar

Brilliant. Sounds like a plan.

Thanks for your help.
Fenn

No problem Fenn,

Here is a screenshot for you:

And the dynamo file:
slabCornerPoints.dyn (6.0 KB)

If this answers your question, please mark the thread as solved. If you need more help with other elements I suggest you start a new topic.

2 Likes

Einar

You’re a star. Works perfectly. Much appreciated.

Fenn

This was a really helpful start point for me, but is there anyway that I can get the length as well. When I run the script I wrote it only detects for clashes on the end points of walls not the actual walls. I’m not sure if this is making much sense, but is there a way around it?

@han.cassone Just plug in Curve.Length to the curve port in the Element.Location node:

@Kevin_Bell A small tip for you: Dynamo provides some methods for converting geometry between Revit and Dynamo, and this takes care of the units as well. See this wiki page: https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration#revitapi
In this case you can use .ToPoint()

for f in walltouses:
	endpoints.append([f.Location.Curve.GetEndPoint(0).ToPoint(), f.Location.Curve.GetEndPoint(1)ToPoint()])

Hi all,

I want to extend this script by linking it with the grids, but I’m stuck with my script.
I can find X and Y coordinates of a certain type of wall, I can find X and Y coordinates of the grids, but does anyone know how to link both?

I want to know the closest intersection of grids to both ends of the wall.
This is my script so far:

@joris.vanbossche Could you please start a new topic? Then it will be much easier for others to find it, and we are keeping the forums tidy. I can help you with the script.

2 Likes

@Einar_Raknes, I did: Begin and endpoint of a wall linked to the closest intersection of grids