Can any one simplify this dynamo to n-number loop

[Warning Cleanup - Highlighted floor overlap.dyn|attachment]
here i want to run for each list so, once you go through it, you we be know

1 Like

@vikas.kpoojary ,

i think it is better to expose a screenshot.

KR

Andreas

2 Likes

ya but its easy to solve with file so i shared

1 Like

It’s no one’s responsibility to “solve” but your own. A screenshot and description explains to us what you are trying to do and what your current process has been. Then we can give you suggestions on how to improve your workflow or where the issue may be. It’s then your responsibility to apply those changes and go from there. No one is here to do your work for you.

There are plenty of threads that cover how to do this, even if they aren’t your exact situation. All you’re trying to do here is setup your main “branch” to work for multiple lists. You can use a sequence node or a code block to create your sequences as a list for the initial inputs.

2 Likes

It’s kinda artistic…

But if someone at my place did that I’d shoot them and their script. :rofl:

2 Likes

You’ve got Python in there already that’s far more complex…

Why don’t you just do a loop and perform the function on each loop?

2 Likes

Ya basically I though it would be easy to understand my problem, were I got stuck. that’s it. nothing else.
I tried with sequence, but the number of lists were varying project to project so… & I don’t have much knowledge with loop function so I am seeking help here.

I don’t have knowledge with loop function, So I am here to get suggestion. and want to learn also.

So as everyone has told you, the script setup is pretty rough, I’d suggest getting your data into a list of sets of walls for each warning (list of lists).

You could then send it through this Python code, where it applies your base Python code as a function to each list instead. If you’re getting into this type of territory it is time to learn Python probably. Never use manual indexing/copying identical code branches per object, try to get your data together and work across it in a list. This sort of thinking will lead you into problems and prevent you developing scripts which scale and work in different scenarios.

I don’t have a test model so can’t guarantee this code is 100% perfect, but in principle should reflect the approach I’d recommend.

import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

walls_list = UnwrapElement(IN[0])

DUT = DisplayUnitType.DUT_MILLIMETERS

def walls_tryToJoin(walls, myDoc = doc):
    joined = []
    for i in walls:
        for j in walls:
            filterIntersect = ElementIntersectsElementFilter(i)
            if i is not j:
                if filterIntersect.PassesFilter(j):
                    joined.append(j)
                    try:
                        JoinGeometryUtils.JoinGeometry(myDoc,i,j)
                    except:
                        pass
                else:
                    point = i.Location.Curve.Origin.ToPoint()
                    curve = j.Location.Curve.ToProtoType()
                    distance = curve.DistanceTo(point)
                    thickF = (i.Width + j.Width)/2
                    thickM = UnitUtils.ConvertFromInternalUnits(thickF,DUT)
                    if distance == thickM:
                        joined.append(J)
                        try:
                            JoinGeometryUtils.JoinGeometry(myDoc,i,j)
                        except:
                            pass
    return joined

TransactionManager.Instance.EnsureInTransaction(doc)

joined_list = []

for walls in walls_list:
    joined_list.extend(walls_tryToJoin(walls, doc))

TransactionManager.Instance.TransactionTaskDone()

OUT = joined_list
3 Likes

Than you, I don’t have any idea of python . I will learn that.

Mainly its a warning were two floor are overlapped but not joined, I am trying join that two floor so when isolating two floor this horrible dyn got created.

1 Like

Where did you get the code from?

from forum