0% found this document useful (0 votes)
100 views2 pages

Codigo Python Ubicacion Grillas

This Python script imports various libraries needed to work with Revit files. It defines a function to find the intersection between two grids passed as parameters. It then collects all grids in the current Revit file, loops through every possible grid pair to find their intersection using the defined function, and returns the closest intersecting grids to a provided point.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views2 pages

Codigo Python Ubicacion Grillas

This Python script imports various libraries needed to work with Revit files. It defines a function to find the intersection between two grids passed as parameters. It then collects all grids in the current Revit file, loops through every possible grid pair to find their intersection using the defined function, and returns the closest intersecting grids to a provided point.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import clr

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import Solid as DynamoSolido
from Autodesk.DesignScript.Geometry import Line as DynamoLine

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

from Autodesk.Revit.DB import Grid as GridRevit

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

#import Document Manager and TransactionManager


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

#import math classes


clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import Math

#Variables de Documento
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

def InterseccionGrillas(grilla1,grilla2):
linea1 = grilla1.Curve.ToProtoType();
linea2 = grilla2.Curve.ToProtoType();
interseccion1 = linea1.Intersect(linea2)

return interseccion1

punto = IN[0]

rejillas1 = FilteredElementCollector(doc)
rejillas1.OfClass(GridRevit).ToElements();

rejillas = list()
for ele in rejillas1:
rejillas.append(ele)

distanciaComparativa = 999999999999
for i in xrange(len(rejillas)):
rejillai = rejillas[i]
for j in xrange(len(rejillas)):
if not (i==j):
rejillaj = rejillas[j]
intersecciones = InterseccionGrillas(rejillai, rejillaj)
if not(intersecciones.Count==0):
distancia = punto.DistanceTo(intersecciones[0])
if distancia<distanciaComparativa:
distanciaComparativa = distancia
rejilla1 = rejillai
rejilla2 = rejillaj

OUT = rejilla1,rejilla2

You might also like