jueves, 3 de noviembre de 2016

Coincident Points on X and Y

In honor of the past "Dia de los muertos" here in Mexico I'm bringing you today's problem.

The continuous struggle of bringing back to life the dead projects that fall on my desk
I've placed a series of points using Autodesk Point layout on all walls in my Revit model.
The client wants one point on each corner of the wall and  - this is the tricky part - the location of the point regarding the wall as a description -Bottom Of Wall or Top Of Wall.


Proposed workflow


Using list of tuples we start filling the description parameters 


The python code will look like this


def coincident(x,y,z):
    el = []
    li = x
    int=1
    #Here start the first part of the workflow
    while int < li.Count:
        i = li[0]
        li.Remove(i)
        for e in li:
        #Round the number to avoid comparing floats
            
            if round(i.Location.Point.X,4) == round(e.Location.Point.X,4) and round(i.Location.Point.Y,4) == round(e.Location.Point.Y,4):
                
                #Here start the second part of the workflow, filling the parameters
                TransactionManager.Instance.EnsureInTransaction(doc)
                if e.Location.Point.Z < i.Location.Point.Z:
                #a= the name of the parameter
                #b = to the code you need to add (BOW, or TOW)
                    e.LookupParameter(a).Set(b)
                    el.append(e)
                else: 
                    i.LookupParameter(a).Set(b)
                    el.append(i)
                TransactionManager.Instance.TransactionTaskDone()
        int+1
    return el

Note that you need to "feed" the function with a list of elements that are point based.


Plot twist:
We could change the code to  set the lower point as 0 and the upper point as the difference between the lower and the upper and then we have the wall actual height as data.


if e.Location.Point.Z < i.Location.Point.Z:
    #a= the name of the parameter
        e.LookupParameter(a).Set("0")
  i.LookupParameter(a).Set(str(i.Location.Point.Z - e.Location.Point.Z))

    else: 
        i.LookupParameter(a).Set("0")
  e.LookupParameter(a).Set(str(e.Location.Point.Z - i.Location.Point.Z))

Hope you find this useful and let me know any comments you have.


No hay comentarios:

Publicar un comentario