0% found this document useful (0 votes)
59 views

Codigo Python

This Python script imports several Revit API modules and defines a function to select faces from the current Revit document. It picks face elements from the user selection, gets the geometry from each face, optionally transforms it based on the element type, tags it with the reference, and adds it to a list to be output.

Uploaded by

ozelwill5388
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Codigo Python

This Python script imports several Revit API modules and defines a function to select faces from the current Revit document. It picks face elements from the user selection, gets the geometry from each face, optionally transforms it based on the element type, tags it with the reference, and adds it to a list to be output.

Uploaded by

ozelwill5388
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import 

clr

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

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

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

def output1(x):
    if len(x) == 1: return x[0]
    else : return x

surfaces, gpoints = [], []


sel1 = uidoc.Selection
ot1 = Selection.ObjectType.Face
ref_list = sel1.PickObjects(ot1, "Pick Faces")
for ref in ref_list:
    el1 = doc.GetElement(ref.ElementId)
    sf0 = el1.GetGeometryObjectFromReference(ref)
    if isinstance(el1, FamilyInstance):
        tf1 = el1.GetTransform().ToCoordinateSystem()
        sf1 = sf0.Convert(ref, tf1)
    else:
        sf1 = sf0.ToProtoType(True)
    for i in sf1: i.Tags.AddTag("RevitFaceReference", ref)
    surfaces.append(output1(sf1) )

OUT = output1(surfaces)

You might also like