Setting values of unaligned walls

Hi all,
I followed this post https://forum.dynamobim.com/t/using-dynamo-to-identify-non-parallel-walls/21246 about fixing the unaligned walls. I’ve fixed the values that I’d want to get but my problem is how can I update the wall angles or say the vector.xaxis with the values that i fixed?

also as an additional info, instead of using dictionary the flattening like on the posted topics. I just get the values that I want to change via python script. here’s the code:

walls = IN[0]
updated_walls = []

for wall in walls:
    if wall == 136:
        updated_walls.append(135)
    elif wall == 46:
        updated_walls.append(45)
    elif wall == 91:
        updated_walls.append(90)
    else:
        updated_walls.append(wall)
        
OUT = updated_walls

thanks in advance!
UnalignedWalls.dyn (26.6 KB)

Hello,
here by tickling the API
class Location
Try to adopt for a wall then make a loop if it corresponds to your expectations.



import clr
import System
import math

from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

elmt=UnwrapElement(IN[0])
ang_radian=IN[1]*math.pi/180
cur_loc=elmt.Location
cur=cur_loc.Curve
end_curv=cur.GetEndPoint(0)
vec_z=XYZ(end_curv.X,end_curv.Y,end_curv.Z+2)
line_axis=Line.CreateBound(end_curv,vec_z)

TransactionManager.Instance.EnsureInTransaction(doc)

rot=cur_loc.Rotate(line_axis,ang_radian)


TransactionManager.Instance.TransactionTaskDone()

OUT = elmt,cur_loc,cur,end_curv,line_axis,rot,ang_radian

cordially
christian.stan

thanks! will try this.

1 Like

just an update, found a solution. Thanks @christian.stan for the tip. I can’t quite follow what’s happening on the api but i made it as a guide to figure out with minimal python script.
so the workflow was:
1.get the angle of the element, find the direction (you would want to rotate the element on the start point as the origin);
2. whatever the angle, catch it so it would go to the nearest 45deg. on my case i made a range of 20deg (+10deg/ -10deg from whatever 45deg)
3. rotate the geometry then set the location.

dynamo script is attached for future reference.
AlignUnparalledWalls.dyn

1 Like