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?
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?
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.
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])
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?
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?
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?
@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.