I was able to create wall geometry from Dynamo. I would like to in the future move it. I have in the past been able to move elements using the Element.SetLocation node, however, I can’t get it to work on walls. Does someone have a simple way to move walls instead of creating new walls?
Kulkul,
It might be how I’ve got it setup. I’m sending in a curve and then a list of elements. Would you mind letting me see the .dyn setup?
Thank you.
I think Element.SetLocation is looking for a point, not a curve.
You need to send points not curves.
Kulkul & Greg, Thank you.
where is Element.Location ?
I can not find it.!!!
@psynan,
it’s in Clockwork Package
Sorry for dredging up an old topic but I can’t find another one.
What am I doing wrong?
Points has no output, curveEndpoints has an output but it doesn’t move the element (wall).
Oh, feeding it curves seems to work .
I was struggling with moving parallel walls with hosted doors. element transform utility does it and chatgbt 01 sorted the rest for figuring out the vector for movement from the location curve and rotation. Although unsure the rotation it implemented was necessary
import clr
# Import Revit Services
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import Revit Nodes
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
# Import Revit API
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
# Inputs from Dynamo
walls = UnwrapElement(IN[0])
curves = IN[1]
TransactionManager.Instance.EnsureInTransaction(doc)
for i in range(len(walls)):
wall = walls[i]
curve = curves[i]
if not wall or not curve:
continue
loc = wall.Location
if not loc:
continue
# Convert Dynamo curve to Revit curve
newCurve = curve.ToRevitType()
oldCurve = loc.Curve
if not oldCurve or not newCurve:
continue
oldStart = oldCurve.GetEndPoint(0)
newStart = newCurve.GetEndPoint(0)
# Build translation vector
translation = XYZ(
newStart.X - oldStart.X,
newStart.Y - oldStart.Y,
newStart.Z - oldStart.Z
)
ElementTransformUtils.MoveElement(doc, wall.Id, translation)
# Calculate rotation
oldDir = oldCurve.Direction.Normalize()
newDir = newCurve.Direction.Normalize()
angle = oldDir.AngleTo(newDir)
cross = oldDir.CrossProduct(newDir)
if cross.Z < 0:
angle = -angle
# Create a rotation axis
# Note: XYZ + XYZ operator is not overloaded in IronPython,
# so we build the second point of the axis manually.
axis = Line.CreateBound(
newStart,
XYZ(newStart.X, newStart.Y, newStart.Z + 1)
)
ElementTransformUtils.RotateElement(doc, wall.Id, axis, angle)
TransactionManager.Instance.TransactionTaskDone()
OUT = walls