-
Notifications
You must be signed in to change notification settings - Fork 0
/
Export2fbx.py
72 lines (55 loc) · 2.02 KB
/
Export2fbx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit import DB
from Autodesk.Revit.UI import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('System')
from System.Collections.Generic import List
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
doc = DocumentManager.Instance.CurrentDBDocument
solid = IN[0]
category = UnwrapElement(IN[1])
solidList = []
solidIds = []
catId = category.Id
TransactionManager.Instance.EnsureInTransaction(doc)
for i in range(len(solid)):
ds = DirectShape.CreateElement(doc, catId)
ds.SetShape(solid[i].ToRevitType())
ds.Name = "Sibi Chakkaravarthy S"
solidList.append(ds)
solidIds.append(ds.Id)
TransactionManager.Instance.ForceCloseTransaction()
fileLoc = "C:/Users/Sibi Chakkaravarthy/Documents/Revi"
fileName = "sibi"
fileName1 = "sibi1.fbx"
#doc = __revit__.ActiveUIDocument.Document
doc1 = DocumentManager.Instance.CurrentDBDocument
#uidoc1 = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
export_ops = DB.FBXExportOptions()
views = DB.ViewSet()
# view must be a 3D view
views.Insert(DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.ActiveGraphicalView)
#__revit__.ActiveUIDocument.ActiveGraphicalView
doc1.Export(fileLoc, fileName1, views, export_ops)
navOp = NavisworksExportOptions()
col1 = List[ElementId](solidIds)
navOp.SetSelectedElementIds(col1)
navOp.ExportScope = navOp.ExportScope.SelectedElements
navOp.ExportRoomGeometry = False
doc.Export(fileLoc, fileName, navOp)
TransactionManager.Instance.EnsureInTransaction(doc)
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = solidIds