Created
June 20, 2020 17:09
-
-
Save chuongmep/54518d6e173a54f344fe41955cf3d34c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Khai báo thư viện | |
import clr | |
clr.AddReference('ProtoGeometry') | |
from Autodesk.DesignScript.Geometry import * | |
clr.AddReference('RevitAPI') | |
import Autodesk | |
from Autodesk.Revit.DB import * | |
FU = Autodesk.Revit.DB.Fabrication.FabricationUtils | |
clr.AddReference("RevitServices") | |
import RevitServices | |
from RevitServices.Persistence import DocumentManager | |
from RevitServices.Transactions import TransactionManager | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import * | |
clr.AddReference('RevitAPIUI') | |
import Autodesk | |
from Autodesk.Revit.UI import * | |
doc = DocumentManager.Instance.CurrentDBDocument | |
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument | |
# Mã chính | |
path = IN[1] | |
def get_selected_elements(): | |
ids = uidoc.Selection.GetElementIds() | |
if isinstance(ids, list) == True: | |
ids=[ids] | |
els = [] | |
for id in ids: | |
el = doc.GetElement(id) | |
els.append(el.Id) | |
return els | |
# Khởi tạo một Transaction để can thiệp vào Revit | |
TransactionManager.Instance.EnsureInTransaction(doc) | |
els = get_selected_elements() | |
FU.ExportToPCF(doc,els,path) | |
TransactionManager.Instance.TransactionTaskDone() | |
OUT = "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment